Let's assume we have recorded two vectors of different lenghts:
a = 1:14;
b = 9:42;
I want both vectors to have a length of 100 (but within the given boundaries (1:length(a) and 1:length(b) respectively).
In the end I will use
a_int = interp1(1:length(a),a,xi_a);
When I calculate my
xi_a = 1:length(a)/100:length(a)
I - no surprise - get only 93 values. So I use
xi_a = 1:(length(a)-1)/100:length(a);
this gives length(xi_a) = 101
So:
xi_a = 1:(length(a)-1)/100:length(a)-((length(a)-1)/100);
gives the exact 100 values for xi_a, but my last xi_a value = 13.8700 and not = 14 as in my original measurement.
How can I manage this within the original x-range and without extrapolation?
I am looking forward to your replies. They are highly welcome
Regards
Stefan
Not sure I understand, but ...
Have you tried linspace?
e.g. linspace(a(1),a(end),100)
Ross
xi_a = 1:(length(a)-1)/(100-1):length(a);
Regards
Stefan
Matlab's INTERP1 is slow. If the input and the output of the interpolation is equally spaced, this function might be helpful:
http://www.mathworks.com/matlabcentral/fileexchange/25463
Example for calling:
x = rand(1, 30);
y = ScaleTime(x, 1, 30, 100);
This scales the values of x from index 1 to index 30 to a vector of 100 elements.
Jan
Thank you. A very handy function. Will certainly use it in the future.
Lieben Gruß nach Heidelberg
Stefan