plot unequal length vectors

14 views (last 30 days)
kokomy
kokomy on 2 Sep 2015
Edited: dpb on 14 Sep 2015
I have a vector X that I want to use for x-axis. Then I have a matrix Y that I want to use for y-axis unequal length. I want to koow how I can plot(X,Y)? X(size)=1x9901 Y(size)= 2x160000

Answers (2)

dpb
dpb on 2 Sep 2015
Edited: dpb on 14 Sep 2015
All you can do there is create some mapping of an X value for each Y; it makes no sense otherwise other than simply by ordinal position ignoring X entirely. Sorry, wish I had better news, but sometimes one simply has insufficient information.
ADDENDUM
Knowing just what the relative sizes are, specifically, doesn't change the basic problem outlined before. You've got to have some reason to associate a given X value with one from Y. The most obvious would be
plot(X.',Y(:,length(X)).')
which uses the first N values of Y to go with X. Or, if the Y observations are somehow known to stretch over the extent of X but were generated on a different sampling rate, you can either interpolate X or decimate Y to make them commensurate in size. The former could be something like
Xi=interp1(1:length(X),X,linspace(1,length(X),length(Y)));
which will return a linear interpolation of the present X values to the number of elements in Y retaining the approximate shape of the X vector with index but lengthening it to have the same number of elements as Y.
If'en you have the Signal Processing Toolbox, there's also resample which will resample up or down in ratio of integers to go either way...

kokomy
kokomy on 2 Sep 2015
How I can create some mapping of an X value for each Y in matlab
  1 Comment
dpb
dpb on 2 Sep 2015
Any way you wish...you've got to have some idea of what X represents in your case and how do the Y values relate. We can't answer that; we've no klew even as to what they stand for, what more where the values came from...

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!