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

1 visualización (últimos 30 días)
Tania Islam
Tania Islam el 18 de En. de 2021
Editada: dpb el 19 de En. de 2021
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 comentario
Rik
Rik el 19 de En. de 2021
You have two sets of y values. What x values are you using?

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 18 de En. de 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 comentarios
Tania Islam
Tania Islam el 19 de En. de 2021
But it showing the following error " Vectors must be the same length."
dpb
dpb el 19 de En. de 2021
Editada: dpb el 19 de En. de 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...

Iniciar sesión para comentar.

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by