How to interpolate a smaller size matrix to a larger size matrix without getting NaN values?
Show older comments
I have a matrix of topography heights that were coarsely sampled (101 x 101 datapoints). I want to use those values to populate a 1001 x 1001 matrix. I have the following code (I actually pass the original values from a text file to Z, but here I have it as randomly-generated number so people don't have to download an additional file - the same issue exists regardless).
What I want is the new matrix to have the same (or similar) values at every 10th element of the new matrix, and fill out the regions inside using interpolation. It looks like it is only filling in the first 101 x 101 elements, and assigning NaN values to everything else. What am I doing wrong, and how to fix it?
Z = rand(101,101); % random 101 x 101 matrix
[Xq,Yq] = meshgrid(1:1001); % finer meshpoints, 1001 x 1001
Vq = interp2(X,Y,Z,Xq,Yq,'cubic');
figure
contourf(Xq,Yq,Vq,64,'Edgecolor','none')
colorbar
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!