discretize two arrays into 50x50 grid

9 ビュー (過去 30 日間)
Hatim Altarteer
Hatim Altarteer 2020 年 7 月 2 日
コメント済み: Hatim Altarteer 2020 年 7 月 2 日
Hello,
i have two arrays:
x_values = [71.2413900000000, 71.2336100000000, 71.2825000000000, 70.9786100000000, 69.1533400000000]
y_values = [-156.334000000000, -156.259000000000, -156.546000000000, -154.674000000000, -158.023000000000]
how can i discretize those 2 arrays into 50x50 grid using imagesc graph function?
thanks!
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 2 日
Are you expecting exactly 5 out of the (50*50) locations to be set to 1, and the rest set to 0?
Hatim Altarteer
Hatim Altarteer 2020 年 7 月 2 日

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 2 日
N = 50;
x_values = [71.2413900000000, 71.2336100000000, 71.2825000000000, 70.9786100000000, 69.1533400000000]
y_values = [-156.334000000000, -156.259000000000, -156.546000000000, -154.674000000000, -158.023000000000]
[xbins, xedges] = discretize(x_values, N);
[ybins, yedges] = discretize(y_values, N);
DiscreteArray = zeros(N,N);
DiscreteArray(sub2ind([N,N], ybins, xbins)) = 1;
imagesc(xedges, yedges, DiscreteArray);
colormap(gray(2))
  1 件のコメント
Hatim Altarteer
Hatim Altarteer 2020 年 7 月 2 日
is there a way to make the axes 50 increments? like it starts from 0 and ends at 50?
thank you so much!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by