How to interpolate the pixel resolution
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to learn interpolation which I will use in my job. These are the code I was practising, but I have error at the end.. Please can someone help me through on how to debug to clear off the error.. Error: Error using griddedInterpolant The grid vectors do not define a grid of points that match the given values.
Error in interp2/makegriddedinterp (line 214)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 127)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in ex_for_interpolation (line 21)
imagesc(interp2(x_axis,y_axis,A,new_x_axis,new_y_axis))
% The codes x_axis = 1:15; y_axis = 1:25;
A = x_axis'*y_axis;
subplot(2,2,1)
imagesc(A)
axis equal
subplot(2,2,2)
% show the same data, but interpolated, by adding one additional pixel to each gap:
imagesc(interp2(A))
axis equal
subplot(2,2,3)
% show the same data, interpolated to any axis of your choice:
new_x_axis = x_axis(1):0.1:x_axis(end);
new_y_axis = y_axis(1):0.2:y_axis(end);
imagesc(interp2(x_axis,y_axis,A,new_x_axis,new_y_axis))
댓글 수: 0
채택된 답변
Jian Wei
2014년 7월 29일
Please try the following code after you create the new_x_axis and new_y_axis.
[x_mesh,y_mesh] = meshgrid(x_axis,y_axis);
[new_x_mesh,new_y_mesh] = meshgrid(new_x_axis,new_y_axis);
imagesc(interp2(x_mesh,y_mesh,A',new_x_mesh,new_y_mesh)')
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!