Pages

Wednesday, 19 February 2014

How to plot 2 Y axis in one window ?

Here the plots had 2 different Y axis parameters and one common  X axis parameter. That time we ll do this process ...

figure
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');

set(get(AX(1),'Ylabel'),'String','Slow Decay')
set(get(AX(2),'Ylabel'),'String','Fast Decay')

xlabel('Time (\musec)')
title('Multiple Decay Rates')

set(H1,'LineStyle','--')
set(H2,'LineStyle',':')

So this is a simple matlab code

The final 2D plot like this


Enjoy

For more info
 http://www.mathworks.in/help/matlab/ref/plotyy.html

No comments:

Post a Comment