plotting lat, lon, altitude, variable

27 ビュー (過去 30 日間)
Sagar
Sagar 2015 年 3 月 9 日
コメント済み: Chad Greene 2015 年 3 月 16 日
I have 3 vectors of latitude, longitude, and elevation respectively. I also have a corresponding 3d matrix of size latitude*longitude*elevation which contains some data (Temperature). I want to display the Temperature data in 3d space. What is the best way to do this? Note: I don't want to use trisurf because it requires reshaping the matrix into 3 separate vectors, with which I found difficulty in tracking the data points.
Many thanks.
-Sagar

採用された回答

Chad Greene
Chad Greene 2015 年 3 月 11 日
You can try pcolor3, although it does not work for Matlab 2014b.
% Some data:
[lon,lat,z] = meshgrid(-180:3:180,-90:2:90,0:50:1000);
T = 20 - .1*abs(lat) - .01*z + sind(lon);
% Plot dataset:
pcolor3(lon,lat,z,T);
% Add labels:
xlabel('longitude')
ylabel('latitude')
zlabel('elevation (m)')
title('temperature or something')
axis tight

その他の回答 (3 件)

Sagar
Sagar 2015 年 3 月 12 日
編集済み: Sagar 2015 年 3 月 12 日
Hi Chad, thanks a lot. I tried pcolor3 that you suggested, but with no success.
Please let me know if I did something wrong. I did:
pcolor3(X, Y, Z, permuted_ext_mean); % X, Y, Z and permuted_ext_mean all have 72*85*208 size.
I got following error in Matlab 2013b. Also, it would be great if you could put a colorbar in the output image. Error using interp3/stripnanwrapper (line 204) Insufficient finite values to interpolate.
The closest one I found for my purpose is isosurface, although I am not completely satisfied: surf2 = isosurface(X, Y, Z, permuted_ext_mean, isovalue);
  4 件のコメント
Sagar
Sagar 2015 年 3 月 13 日
Yes, a lot of NaN values. Just tried the updated one, works well now. It is a bit slow though compared to isosurface, may be it is normal for pcolor.
-Sagar
Sagar
Sagar 2015 年 3 月 14 日
編集済み: Sagar 2015 年 3 月 14 日
Here is what I got with pcolor3, I am fully satisfied now. Thanks Chad.

サインインしてコメントする。


Chad Greene
Chad Greene 2015 年 3 月 14 日
Great! You may also want to add a coast line for context as shown here.
  1 件のコメント
Sagar
Sagar 2015 年 3 月 15 日
編集済み: Sagar 2015 年 3 月 15 日
Hi Chad, that is a great suggestion and I am trying to do that as below. Is there a way to specify the range of latitude and longitude, say, in my case, 0 to 40N, -20 to 70E (so the length of the two vectors would be unequal). c = load('coast.mat'); plot(c.long,c.lat) view (3)

サインインしてコメントする。


Sagar
Sagar 2015 年 3 月 15 日
Never mind! I was able to plot as I wanted with a small tweak. This is what I did:
load ('coast.mat');
long (long < -20 | long > 70 = NaN;
lat (lat < 0.00 | lat > 40.00) = NaN;
plot (lat, long);
  1 件のコメント
Chad Greene
Chad Greene 2015 年 3 月 16 日
Or similarly,
in = ingeoquad(lat,long,[0 40],[-20 70]);
long(~in) = NaN;
lat(~in) = NaN;

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeClimate Science and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by