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

조회 수: 1 (최근 30일)
Tania Islam
Tania Islam 2021년 1월 18일
편집: dpb 2021년 1월 19일
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
Rik
Rik 2021년 1월 19일
You have two sets of y values. What x values are you using?

댓글을 달려면 로그인하십시오.

답변 (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