I have two data vectors $y1$ and $y2$, and I want to plot both of them as functions of the vector $x$. I want the result to be two overlapping curves. Here is the set of commands I am using.

y2=[0.003,0.003,0.011,0.011,0.015,0.020,0.023,0.024,0.024,0.024,0.024,0.024,0.024,0.025,0.024,0.024,0.024,0.024,0.024,0.024,0.023,0.023,0.021,0.019,0.019,0.018,0.016,0.013,0.011,0.009,0.009,0.009]; y1=[0.003,0.003,0.003,0.010,0.031,0.050,0.060,0.065,0.070,0.074,0.079,0.085,0.087,0.087,0.091,0.090,0.090,0.086,0.083,0.079,0.074,0.062,0.055,0.047,0.044,0.035,0.032,0.026,0.018,0.013,0.013,0.013,0.003]; x=[20,70,100,150,200,220,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,400,450,500,550,600,700,800,1000,1500,2000,2500,3000]; plot(x,y1,y2).

Which does plot the vectors, except that $y2$ is mapped from 0 to 20, while $y1$ is mapped from 20 to 3000. Here is the result from the above command. enter image description here

$y2$ is the orange graph. I can't really describe the problem any better than this. How should I rewrite my commands so that $y2$ is also mapped from 20 to 3000?


1 Answer 1




but make sure that y2 is of the same size as y1, because in your example that isn't the case.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.