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.
  1. clc: clear command window
  2. clear: Remove all saved items from workspace, free system memory
  3. close all: close all figures
  4. figure: create figure each time separately, used when there are many figures in one program
  5. hold: Retain current graph in figure
  6. plot: plot signals
  7. subplot: plot many signals separately
  8. xlabel: gives text on x-axis
  9. ylabel: gives text on y-axis
  10. title: gives title text on top of the figure
  11. gird on: Grid lines for 2-D and 3-D plots
  12. stem: plot in discrete time signals
  13. axis: AXIS Control axis scaling and appearance.
  14. legend: puts a legend on the current plot using the specified strings as label
  15. text: TEXT (X,Y,'string') adds the text in the quotes to location (X,Y)  on the current axes
  16. box:  BOX    Axis box.
  17. Linspace: Generate linearly spaced vectors
  18. Input:  Request user input.
  19. Save: SAVE Save workspace variables to file.
  20. Zeros: Create array of all zeros
  21. Ones: Create array of all ones
Merge signals by Using hold on command

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

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel