How can I duplicate the array data into a fixed number?

1 view (last 30 days)
Hello,
I have an array size of 240 data. But to plot that data into the figure I need 1000 data as my another dataset is 1000.
How can I increase my dataset to 1000 from 240 by using the existing dataset?

Answers (1)

dpb
dpb on 18 Jan 2021
No, you don't have to have the same number of points in both lines to plot them on the same axes.
Use
plot(x1,y1,x2,y2)
or
plot(x1,y1)
hold on
plot(x2,y2)
You could, of course, use interp1 and create more points, but it's totally unnecessary to do so.
  2 Comments
Tania Islam
Tania Islam on 19 Jan 2021
But it showing the following error " Vectors must be the same length."
dpb
dpb on 19 Jan 2021
Edited: dpb on 19 Jan 2021
Well, you do have to match the x,y vectors of the same line...do you mean you have an x and y that are disparate sizes? How did you manage that out of curiosity?
>> plot(1:10,rand(1,10),'k-',1:20,randn(1,20),'r-*')
gives
But, yes, the two lines' x and y each have the same length; figured that was a given.
As noted, if really do have an x and a y that are different in size but belong together, then you'll either interpolate the shorter to match the longer or decimate the longer to match the shorter.
But that leads to the question of how do you know which of the longer section belongs to which of the shorter?
We need more explanation of what you really have and how you got it to be able to follow the problem...

Sign in to comment.

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!