Interpolation of matrix with data that is of different dimensions
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
James Rodriguez
am 13 Mär. 2021
Kommentiert: Walter Roberson
am 13 Mär. 2021
The code below attempts to interpolate from a matrix (13x10) which contains velocities corresponding to some x points(1x10) and y points (13x1). I need to find the velocity for the same 10 x points but with different y points (10x1). I have tried the following to interpolate the matrix, however, I can't get a code that runs. Am I using the correct technique? If so why isn't this working? And if not then I am grateful for any assistance.
x_points = [3,6,9,12,15,18,21,24,27,30]; % X values for the function
y_points = [1,2,3,4,5,6,7,8,9,10,11,12,13]; % Y values for the function
Yq = [12.7,11.16,11.68,10.99,12.98,3.61,9.291,0.18,9.86,3.64] % The points for which I need the function value
Xq = x_points
F = interp2(x_points,y_points,V1,x_points,interpolate_me); % Output the matrix withe the data
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Mär. 2021
Bearbeitet: Walter Roberson
am 13 Mär. 2021
V1 = sort(randi(9,13,10));
x_points = [3,6,9,12,15,18,21,24,27,30]; % X values for the function
y_points = [1,2,3,4,5,6,7,8,9,10,11,12,13]; % Y values for the function
Yq = [12.7,11.16,11.68,10.99,12.98,3.61,9.291,0.18,9.86,3.64] % The points for which I need the function value
Xq = x_points
F = interp2(x_points,y_points,V1, Xq, Yq); % Output the matrix withe the data
F
The Nan is because the Y query 0.18 is before any define y coordinate.
2 Kommentare
Walter Roberson
am 13 Mär. 2021
Not really. There is a temptation to say "use interp3" with the third coordinate being the function number, but the problem with that is that it will mix between functions. Though maybe if you used a third coordinate that was on a much larger scale then the mixing would be minimal.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!