interpolating different row sizes
1 view (last 30 days)
Show older comments
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
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...?
Answers (1)
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
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.?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!