Basics of MatLab (Matrix Library)
The software MatLab (abbreviation for MATrix LABoratory) was end of the 70s with ¨The goal developed important algorithms of numerical linear algebra, such as the solutions of linear equation systems, eigenvalue computations, etc. in an interactive environment through simple and intuitive use of function calls. Even though Matlab also allowed symbolic calculations, the emphasis is in contrast toComputer algebra systems are primarily concerned with the numerical treatment of mathematical problems, i.e the calculation with finite precision.
Getting started with Matlab
Start Matlab by double-clicking the left mouse button (cll) on the Matlab icon or the matlab.exe file
Quit Matlab by typing quit, exit, or Ctrl + Q.
Matlab Desktop
Command-Window (always available)
Enter the commands after the Matlab prompt: >>. After a% sign is the rest
the line comment.
Default variable is ans (Answer)
>> (40 ° 3 + 3 * 2e3) / 7% input of the user
ans =% reaction of Matlab
1000% reaction from Matlab
Editor (always available)
Open by entering edit in the command window, allows the creation of MDateien.
Any input in the Command window can also be written to an M file and then be processed by entering the file name as a script.
Command History (newer Matlab versions only)
Lists the commands entered in the Command window. The commands can be changed by ↑ and ↓ scroll, repeat with cll or copy & paste into an M-file and copy work off again.
Workspace Browser (newer Matlab versions only)
Displays the content of the current workspace, so defines variables and their structure, etc.
Current Directory Browser (newer Matlab versions only)
Displays the current directory (for example, a listing of the M files there).
Profiler (newer Matlab versions only)
Shows usage and CPU time usage of individual commands in Matlab scripts.
Shortcut bar (depending on version)
Enables you to call frequently used commands by clicking (cll).
Basic Commands:
Help: HELP lists a description of all operators and special characters.
Doc: DOC opens the Help browser, if it is not already running, and otherwise brings the Help browser to the top.
- clc: clear command window
- clear: Remove all saved items from workspace, free system memory
- close all: close all figures
- figure: create figure each time separately, used when there are many figures in one program
- hold: Retain current graph in figure
- plot: plot signals
- subplot: plot many signals separately
- xlabel: gives text on x-axis
- ylabel: gives text on y-axis
- title: gives title text on top of the figure
- gird on: Grid lines for 2-D and 3-D plots
- stem: plot in discrete time signals
- axis: AXIS Control axis scaling and appearance.
- legend: puts a legend on the current plot using the specified strings as label
- text: TEXT (X,Y,'string') adds the text in the quotes to location (X,Y) on the current axes
- box: BOX Axis box.
- Linspace: Generate linearly spaced vectors
- Input: Request user input.
- Save: SAVE Save workspace variables to file.
- Zeros: Create array of all zeros
- Ones: Create array of all ones
close all
clear all
clc
T=0.001;
t=-0:T:2;
f=1
x=sin(2*f*pi*t)
plot(t,x)
grid on
hold on
T=0.001;
t=-0:T:2;
fo=2
x=cos(2*fo*pi*t)
plot(t,x,'r')
grid on
Impulse Function:
clear all;
close all;
clc
y=[zeros(1,5), ones(1,1), zeros(1,5)]
stem(y)
grid on
Using Input command with Zeros & Ones:
clc
n=input('Sir, Enter the value of zeros:');
p=input('Mam, Enter the value of ones:');
y=[zeros(1,n), ones(1,p), zeros(1,n)];
stem(y);
OUTPUT: (Figure) – After putting values in command window we get the output
Using input command asking frequency:
clc
close all
T=0.001;
t=-5:T:5;
pi=1;
A=1;
f=0.2;
f1=0.3;
f=input('please enter frequency1 value=');
f1=input('please enter frequency2 value=');
x=A*sin(2*pi*f*t);
hold on
plot(t,x,'G')
x2=A*sin(2*pi*f1*t);
plot(t,x2,'K');
grid on
legend('x','x2')
OUTPUT: (Figure) – After putting frequency, we get the output
0 Response to "Basics of MatLab (Matrix Library)"
Post a Comment