1,114 views (last 30 days)

Matt Fig
on 16 Oct 2012

Edited: Matt Fig
on 16 Oct 2012

If you know the starting time and ending time for the amplitude, you can just make your own time vector of the correct length.

t = linspace(beginningtime,endingtime,length(y));

plot(t,y)

This assumes the y data was sampled at equal time spacings. If that is not the case, you should give more information about how you ended up with two vectors of different lengths and the relationship between t(idx) and y(idx) for a given idx.

Jos (10584)
on 24 Feb 2016

You can use interpolation

X_known = [1 2 3 6 8 10] ;

Y_known = [2 5 6 11 18 23] ;

X_desired = 1:10

Y_desired = interp1(X_known, Y_known, X_desired)

plot(X_desired, Y_desired,'rs-', X_known, Y_known,'bo')

Sign in to comment.

Flavio Baduini
on 3 Apr 2016

Edited: Flavio Baduini
on 3 Apr 2016

The question is of primary importance, I'm facing the same while plotting raw and averaged sensors data.

.

ex:

raw data: y (a vector of length 1000)

averaged data: z (a vector of length 100)

.

You can define a common x-axis and plot your vectors with respect to that. I chose time and I made an average of time values for each 10 samples (10 because I'm averaging 10 values each):

.

time: t (a vector of length 1000)

time averaged: ta (a vector of length 100)

.

Now just plot the values with the same length and you'll get two graphs with the raw and averaged data, in the same plot and with the correct spacing

.

plot(t,y)

plot(ta,z)

Sign in to comment.

kavya k
on 16 May 2017

Jan
on 16 May 2017

Jan
on 16 May 2017

Sign in to comment.

SABRINA SABRINA
on 23 Apr 2019

hi

I have a file.txt which has 20 points following x and 17 points following y with combinations E = 20 * 17 points I want to draw E in the xy plane BUT it displays error because they do not have the same dimensions

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.