Interpolation of matrix with data that is of different dimensions
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2021년 3월 13일
편집: Walter Roberson
2021년 3월 13일
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
Walter Roberson
2021년 3월 13일
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.
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!