0

So I have this function that I modified slightly that takes in a "main" vector and a "base" vector and stretches/compresses the main vector to the dimensions of the base vector.

function output = stretch(main, base)
N=length(main)-1;
X=0:N;
XI=0:(length(main)/length(base)):N;

output=interp1(X,main,XI);
end

The base vector always has a length of 1620 so that is the goal. This works most of the time, but for some "main" vector dimensions, the vector of the stretched/compressed vector is 1619 or 1618. I have no idea how to apply a correction for this - any thoughts?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ktosayev
  • 17
  • 5

1 Answers1

0

@David wrote:

Use linspace(intialValue,finalValue,numberOfElements) not intitialValue:increment:finalValue.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129