Friday, November 12, 2010

MATLAB-4(LEGEND,HOLD ON)

in this article i want to discuss the following things.
1.legend
2.hold on
the function legend is used to describe the various graphs with some identification so that any one can understand what each graph is ment for.
observe the following code:

x=0:1:10;
y1=x.^2;
y2=x.^3;
plot(x,y1,x,y2);
legend('y=x^2','y=x^3');
observe the result of this code:


from the above graph we can observe that because of the legend function we r getting y=x^2 and y=x^3 on the top of the graph with colors.................
now lets discuss about 'hold on':
hold on fixes all the properties of axes remain so that we can plot the graphs in one window.observe the following code:
x=0:.1:10;
y1=x.^2;
y2=x.^3;
y=x;
plot(x,y1);
hold on;
plot(x,y2);
plot(x,y);
the result of this graph is;

from the above graph we can say that all the graphs are present in a single window..............and this is possible only because of the 'hold on'.thats it..................

No comments:

Post a Comment