How to draw plot with just one variable

Hello, I have one quick question. I have one variable which is an vertical array and 'y' of my desired plot. The size of it is as of now 39x1 but it can vary from what are the conditions of simulation. I would like to plot it but I have only the span of my 'x' axis (eg. 0:myothervariable(end)). So how do I create variable that contains values within desired span of my 'x' axis yet it remains the same size as the 'y' variable so I can plot it.
Thank you for your help!

 采纳的回答

I am not certain what you want to do.
Try this:
y = randi(9, 39, 1);
myothervariable = 1:50;
ynew = interp1(y, myothervariable);
figure(1)
plot(myothervariable, ynew)
It interpolates ‘y’ to the size of ‘myothervariable’, then plots it. Note that for this to work, ‘myothervariable’ has to be monotonically increasing, as required by interp1.

更多回答(0 个)

类别

产品

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by