フィルターのクリア

X Y scatter data Color Contour of Frequency Distribution spatially

2 ビュー (過去 30 日間)
Utsav
Utsav 2016 年 2 月 3 日
コメント済み: Utsav 2016 年 2 月 3 日
I have X Y scatter data ranging from -125km to +125km in both X and Y.
In 5 by 5 km box I want to find number of points, divide it by total number of points in the entire grid(250km*250km box) and get some number Z and assign relevant color to that box pertaining to the achieved value Z.
Is there any way doing it?

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 3 日
  3 件のコメント
Walter Roberson
Walter Roberson 2016 年 2 月 3 日
編集済み: Walter Roberson 2016 年 2 月 3 日
Caution: the below will fail if you have any data at X = +125 or greater or Y = +125 or greater. If you have data right at both boundaries then you need extra bins. If your data can be +125 exactly but cannot be -125 exactly then in the below change the 1 + floor() to be 0 + ceil()
binmin = -125; binmax = 125; binwidth = 5;
xbin = 1 + floor((X(:) - binmin) / binwidth);
ybin = 1 + floor((Y(:) - binmin) / binwidth);
nbins = ceil((binmax - binmin) / binwidth);
counts = accumarray([xbin, ybin], 1, [nbins, nbins]);
Z = counts ./ numel(counts);
coords = [binmin, binmin + (nbins-1)*binwidth];
image(coords, coords, Z);
colormap(hot)
Utsav
Utsav 2016 年 2 月 3 日
Thanks a lot Sir, for the reply. It worked for me. Also I found the use of "accumarray' in this link

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by