How can I duplicate the array data into a fixed number?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
dpb
am 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 Kommentare
dpb
am 19 Jan. 2021
Bearbeitet: dpb
am 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...
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!