interpolating different row sizes

1 view (last 30 days)
Evan
Evan on 14 Nov 2013
Commented: Image Analyst on 15 Nov 2013
Hello,
I have a problem, I want to display a height 'H' over a period of time 'T' but the vectors don't have the same length, I thought I could use the 'interp1' function like this:
for j= 1:1:length(T)
H1(j) = interp1(T,H,T(j));
end
the T vector is 229 units long and the H vector is 4091.
but I get this error: "Error using griddedInterpolant The grid vectors do not define a grid of points that match the given values."
I don't know which function to use.
  1 Comment
Walter Roberson
Walter Roberson on 14 Nov 2013
For any particular entry H(K), what time is it associated with? Is T a subset of the times implied over H and you want to select that subset? Or is the total time of T implied to be the same as the total time of H and you want to know the H values at the particular times listed in T? Or...?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 14 Nov 2013
Edited: Image Analyst on 14 Nov 2013
Is T uniformly spaced? If so, just try this
Tnew = linspace(T(1), T(end), length(H));
plot(Tnew, H, 'b-');
  2 Comments
Evan
Evan on 15 Nov 2013
it is uniformly space, but I forgot o tell thatI have another vector the same length as T but not uniformly spaced which I have to plot in the same figure
Image Analyst
Image Analyst on 15 Nov 2013
What do you have that tells what the "x" or "t" value is at those samples? If you have T at 1,11,21,31 then that's fine. But if you have S values sampled at 1,4,15,19,45,60, etc. (essentially at non-uniform spacing) then how will we know that S(1) was at 1, and S(2) was at 4, etc.?

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!