Interpolation of matrix with data that is of different dimensions
3 次查看(过去 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!