interpolate (extrapolate?) the values in between two matrices using existing data
Ältere Kommentare anzeigen
Hello all,
I have two matrices A and B that are plotted below:
A = [1, 2, 3, 4, 5; 0.3654, 0.3634, 0.3663, 0.3665, 0.3677];
B = [16, 17, 18, 19, 20; 0.4653, 0.4636, 0.4652, 0.4620, 0.4715];
figure; plot(A(1,:),A(2,:),'-o')
hold on; plot(B(1,:),B(2,:),'-o')
How can I use the y values of these two matrices to identify y values where X=6:15?
I know I can do this by finding the slope of the line between the average of vector A and average of vector B and then, populate the values in between. But I am curious to learn if there is a more precise way? Is there a modified version of interp1 that can serve this purpose?
Akzeptierte Antwort
Weitere Antworten (1)
A = [1, 2, 3, 4, 5; 0.3654, 0.3634, 0.3663, 0.3665, 0.3677];
B = [16, 17, 18, 19, 20; 0.4653, 0.4636, 0.4652, 0.4620, 0.4715];
figure; plot(A(1,:),A(2,:),'-o')
hold on; plot(B(1,:),B(2,:),'-o')
C=[6:15]; C(2,:)=zeros(numel(C),1);
C(2,:)=interp1([A(1,end),B(1,1)],[A(2,end),B(2,1)],C(1,:));
plot(C(1,:),C(2,:),'-o')
To join the lines, incorporate A,B into the vector to evaluate for C, of course.
Can 'spearmint with various other interpolation schemes besides linear, of course, although with the toy data there's no real apparent connection between the two segments, one presumes this is just for show, not the real problem.
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


