フィルターのクリア

How to make pcolor plot from three vector

8 ビュー (過去 30 日間)
Aristo
Aristo 2017 年 9 月 6 日
コメント済み: Aristo 2018 年 1 月 12 日
I have matrix A of size 3X250, where in the value of altitude corresponds to longitude and latitude
A= [latitude, longitude, altitude]
I want to plot pcolor for latitude and longitude with bin/grid size of 5 degree, where in bin should contain mean data of altitude within the 5 degree bin and should reflect in the colorbar. The plot should look somewhat like the following
Thanks for your inputs in advance

採用された回答

Kelly Kearney
Kelly Kearney 2017 年 9 月 6 日
You can calculate the bin averages pretty quickly using discretize and accumarray:
Some sample data:
npt = 10000;
A = [rand(npt,1)*180-90 rand(npt,1)*360-180 rand(npt,1)];
5-degree bins:
latbin = -90:5:90;
lonbin = -180:5:180;
nlat = length(latbin);
nlon = length(lonbin);
Use discretize to figure out which latitude and longitude bin each point falls into, then convert the row/column indices into a single array index.
ilat = discretize(A(:,1), latbin);
ilon = discretize(A(:,2), lonbin);
idx = sub2ind([nlat nlon], ilat, ilon);
Use accumarray to average the values assigned to each index, then reshape to a grid:
altg = accumarray(idx, A(:,3), [nlat*nlon 1], @(x) mean(x), NaN);
altg = reshape(altg, nlat, nlon);
Finally, plot:
pcolor(lonbin, latbin, altg);
  1 件のコメント
Aristo
Aristo 2018 年 1 月 12 日
I wanted to apply 'shading interp' for the above code, If one of them is Nan, this point is not coloreated since the interpolation is between 4 vertices, what is the other alternative for it

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by