Plot bilinear interpolated gridded data spatially on a map (Cannot get Interp2 to give smooth output)

조회 수: 1 (최근 30일)
I am using the following code to plot gridded data on a map over a region but I would like to know how to plot the interpolated data so that I get continuous data plotted over the region and the data does not look gridded. 'lat' and 'lon' are vectors (1x21 and 1x33) containing the latitude and longitude coordinates respectively.
ax = worldmap(latlim, lonlim);
S = shaperead('landareas','UseGeoCoords',true);
surfacem(lat, lon, ans');
geoshow([S.Lat], [S.Lon],'Color','black');
I am seeing a lot of documentation on using interp2 but I am not getting mine to work even when I try to create a meshgrid using lat and lon (cannot attach the data). I do the following with interp2:
LON,LAT] = meshgrid(unique(lon),unique(lat));
interp2(lon, lat, testdata', LON, LAT);
That gives me a result but I then want to plot it over a region without it looking gridded. testdata is a 33x21 matrix. Any ideas? I have seen some examples here on interpolation but I am not sure how to apply it conveniently with the data I have. I am surprised that there is not more information on this or why I am just sucking at finding the answer!
Thanks,

채택된 답변

Chad Greene
Chad Greene 2015년 8월 29일
Something to keep in mind: If you only have 33x21 actual data points, a smooth surface plot that does not look gridded will imply to the viewer that you have much higher resolution data than you actually do. But sometimes that's okay. You might not need to use interp2. Instead, simply follow your surfacem command with
shading interp
  댓글 수: 1
mashtine
mashtine 2015년 9월 1일
Ah! Finally, I can see the light. Many thanks, Chad. It is a bit tricky at time knowing the completely functionality of these packages at times. When I apply this interpretation by the way, my map borders are removed on the first subplot. Any ideas what may be causing this?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by