THE PLOT,FPLOT,FUNCTION COMMAND MATLAB

THE PLOT COMMAND
If a vector x has the elements 1, 2, 3, 5, 7, 7.5, 8, 10, and a vector y has the elements 2, 6.5, 7, 7, 5.5, 4, 6, 8, a simple plot of y versus x can be created by typing the following in the Command Window:

>>  x=[1 2 3 5 7 7.5 8 10];
y=[2 6.5 7 7 5.5 4 6 8];
plot(x,y)


>> yr=[1988:1:1994];
>> sle=[8 12 20 22 18 24 27];
>>  plot(yr,sle,'--r*','linewidth',2,'markersize',12)



The plot of a Function
>> x=[-2:0.01:4];
>> y=3.5.^(-0.5*x).*cos(6*x);
>> plot(x,y)
THE fplot COMMAND
fplot('x^2+4*sin(2*x)-1',[-3 3])



Post a Comment

0 Comments