|
"Chris " <chris.barr@health.sa.gov.au> wrote in message <hdvcv2$1b$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <hduc11$t14$1@fred.mathworks.com>...
> >
> > "Chris " <chris.barr@health.sa.gov.au> wrote in message
> > news:hdt44e$fe$1@fred.mathworks.com...
> > > This should be quite simple,
> > >
> > > I have numerous vectors of varying length. I want them all to be 1x100
> > > vectors so I can compare them. I did this years ago but have not used
> > > matlab for a while and cannot remember how. Your help is appreciated.
> >
> > That depends.
> >
> > If you just want to chop off the end of those signals that are longer than
> > 100 elements:
> >
> > x = x(1:100);
> > % or
> > x(101:end) = [];
> >
> > If you want to pad those vectors that are shorter than 100 elements with NaN
> > values:
> >
> > x = [x; NaN(100-numel(x), 1)] % Assuming x is a column vector
> > x(end+1:100) = NaN;
> >
> > If you want to interpolate the values in your vector to obtain the value at
> > a vector of 100 uniformly-spaced times, look at INTERP1 or the DECIMATE
> > function from Signal Processing Toolbox.
> >
> > If you have another method that you want to use to shrink/grow the vectors
> > to be 100 elements long, describe that method and someone here may be able
> > to help you implement it (or describe which function that already exists
> > implements it.)
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
>
>
> Thanks Steven, I tried the interp1 command yesterday, and it didn't work. For some reason it is working fine today.
>
> %A is vector of 3019 values
> x=[1:100];
> Ai = interp1(A,X);
> %Ai is a vector of 100 values from A equally spaced.
>
> Regards
>
> Chris
Sorry, this is not what I was after. This solution only gives the first 100 values of A.
what I have is vectors
A <1x3019>
B <1x2346>
C <1x4529>
etc etc
these are values (angles) taken over time taken to complete a task. I want to normalise these so that the full range of data is there, but so that all new vectors are <1x100>
For example, if I had values [1, 2, 3] and I wanted it to be a vector of length 5 instead of 3, the new values would be [1, 1.5, 2, 2.5, 3]
I hope that makes more sense.
Chris
|