There is several data that I want to plot in one figure, but they are with different sample times, as some are gotten from measurements, while others are gotten from simulations. Also, some of the relative values may be very different, so I need to show them in different axises, for now I choose plotyy .
When they are with the same sample time, the code works well, as follows,
x = 0:1:10; % Sample Time is 1000ms
y1 = sin(x); % y1~y5 with the same time
y2 = cos(x);y3 = 10*sin(x/2);y4 = 10*cos(x/2);y5 = x;%-------------------------
figure[handle_DualAxes,handle_line1,handle_line2] = plotyy(x,[y1;y2],x,[y3;y4;y5]);
But when I use this method with different sample times, like
x1 = 0:0.01:10; % Sample Time1 = 10ms
x2 = 0:1:10;% Sample Time2 = 1000ms
y1 = sin(x1);%With sample time1
y2 = sin(x2);%With sample time12
y3 = 10*sin(x1/2);%With sample time1y4 = 10*sin(x2/2);%With sample time2
y5 = x2;%With sample time2%-------------------------figure[handle_DualAxes,handle_line1,handle_line2] = plotyy([x1;x2],[y1;y2],[x1;x2;x2],[y3;y4;y5]);
Error message accurs,
??? Error using ==> vertcatCAT arguments dimensions are not consistent.Error in ==> Dual_Axes_Try at 47[handle_DualAxes,handle_line1,handle_line2] =plotyy([x1;x2],[y1;y2],[x1;x1;x2],[y3;y4;y5]);
How should I use the plotyy here? Or if there is any other way to draw this figure. Thanks.
Best Answer