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

2 次查看(过去 30 天)
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?

回答(1 个)

dpb
dpb 2021-1-18
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 个评论
Tania Islam
Tania Islam 2021-1-19
But it showing the following error " Vectors must be the same length."
dpb
dpb 2021-1-19
编辑:dpb 2021-1-19
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...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by