Matlab Program to Plot Multi Curves in One Figure with Legends!
Solution:
%=============================================
%=Plotting 2 Graphs at the same figure with Legends!=
%=============================================
X=[-1:0.01:1];
Y=exp(X.^2);
plot(X,Y)
hold on
X=[-1:0.01:1];
Y=sin(X);
plot(X,Y,'r')
xlabel('(X) values')
ylabel('(Y) values')
title('Functions y = exp (X^2) and y = sin (x) ')
legend('exp (x^2)','sin (x)',2);
%**************************************************************
Another Example: Write Matlab program script to plot 5 curves using x column vector values 1:1000 for the function y = Log(x)?
Solution:
%======================================================
%= Plotting Multiple curves of a function using a vector elements=
%======================================================
x=(1:1000)'; % Transpose of a row vector!
% Or, we can write it: x = [1:1000;];
for k =1:5
y(:,k)=k*log10(x);
end
plot(x,y)
title('Multi Curves Plot!');
xlabel('x vector values');
ylabel('y = log (x)')
legend('log(x)','2log(x)','3log(x)','4log(x)','5log(x)');




0 Comments:
Post a Comment
السلام عليكم...سارد بعد قرائتي للتعليق...شكرا
<< Home