简体   繁体   中英

Overlay 3D Surface Plot over 3D Globe in MATLAB

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 line plot3m(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

surfm(lat(1:200),long(1:200), rand(200,200))

to randomly color a part of the south pole.

By the way, shouldn't your last line read surfm(latitude,longitude,elevation) ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM