Professional Documents
Culture Documents
EE 2303 Lab
Welcome to Matlab
MATLAB stands for Matrix Laboratory APPLICATIONS OF MATLAB:
Mathematical Calculations
Getting Started
Command- History
FILE
NEW
M-FILE
clear all: clears workspace of all variables close all : closes all the figure windows plot (x,y) : plots vector y versus x % : used for Comments help : when used with command gives its syntax
help Command
cos (): Generates a cosine wave sin() : Generates a sine wave square(): Generates a square wave square( ,duty): Generates a square with specified duty cycle sawtooth(): Generates a sawtooth wave sawtooth(t,0.5): Generates a triangle wave
Sine-wave Generation
clear all; close all; frequency=1000; timeperiod=1/frequency; amplitude=1; dcoffset=0; t=0:0.00001:2*timeperiod; out=dcoffset+amplitude*cos(2*pi*frequency*t); plot(t,out);
Sine-wave Generation
clear all; close all; frequency=1000; timeperiod=1/frequency; amplitude=1; dcoffset=0; t=0:0.00001:2*timeperiod; out=dcoffset+amplitude*cos(2*pi*frequency*t); plot(t,out);
0.2
0.4
0.6
0.8
1.2
1.4
1.6
1.8 x 10
2
-3
More Commands
xlabel( ) : Allows you to label x-axis ylabel( ) : Allows you to label y-axis title( ) : Allows you to give title for plot subplot() : Allows you to create multiple plots in the same window