Monday 29 December 2014

plotting functions in matlab



Plotting Functions in MATLAB

MATLAB has build in function that allow one to generate x-y polar, contour and three-dimensional plots and bar charts. MATLAB also allow one to give title to graph, label the x and y axis, and a grid to graph. In addition, there are commands for controlling the screen and scaling.
X-Y Plot and annotations:
The Plot command generates a linear-y plot. This command has three variations.
Plot(x) 
Plot(x,y)
Plot (x1,y1,x2,y2,x3,y3,....Xn,Yn,)
If x is a vector, the command PLOT(x) is used.
if x and y are vector of the same length, then the command plot(x,y) is used.
Plot(x1,y1,x2,y2,x3,y3,.....Xn,Yn) is used for multiple arguments.
To write text on a graphic screen beginning at a point (x,y) on the graphic screen, one can use command text(x,y, 'any text')

Example:
t=0:0.25:7;
y =sin(t);
plot(t,y)

 
Example: Response of an RC Circuit:

Solution:
MATLAB Script

T=0:0.5:4;
Y=6*ept(-2*t);
Plot(t,y);
Title('Response of an RC Circuit:')
Xlabel(' Time in seconds')
Ylabel('Voltage in volts')
Grid 

Voltage and current of an RL Circuit:
For an RL Circuit, the voltage v(t) and current i(t) are given as:
V(t)=10cos(377t)
I(t)=5cos(377t+60o)

Solution: 
MATLAB Script

 

 

Posted in:

0 comments:

Post a Comment