I want to place a 3d surface plot over a globe in MATLAB. I can’t get it to work.
Here is the code:
% Sampele Data
longitude = [1 2 3]
latitude = [3 2 1]
elevation = [12 21 13; 15 14 15; 12 16 15]
% Create Globe
figure
axesm('globe')
gridm('GLineStyle','-','Gcolor',[.8 .7 .6],'Galtitude', .02)
load coast
plot3m(lat,long,'k')
view(3)
axis off; zoom(2)
% Overlay Surface Plot
mesh(longitude,latitude,elevation)
surfm(longitude,latitude,elevation)
Although it is not obvious, your code actually seems to work fine.
To see it, first remove the line
mesh(longitude,latitude,elevation)because it does not plot in longitude-latitude coordinates.The problem now is that the
surfm(longitude,latitude,elevation)only draws a tiny area which is hard to spot. Too locate it, comment out the lineplot3m(lat,long,'k'), run the script and notice your tiny surface in the right half of the globe.To demonstrate that your script is working, you could also replace the last line by
to randomly color a part of the south pole.
By the way, shouldn’t your last line read
surfm(latitude,longitude,elevation)?