Discretize and categorize data

1 回表示 (過去 30 日間)
Elin Jacobs
Elin Jacobs 2022 年 12 月 9 日
回答済み: Elin Jacobs 2022 年 12 月 9 日
Hello,
I have two arrays of same size with values ranging from 0-1. I want to first discretize the values in each array and hten create a new array that give all possible combination a unique value, something like
classes(a ==1 & b ==1 ) = 1;
classes(a ==1 & b == 2) = 2;
...
classes(a == 7 & b ==7) = 49;
My dummy code is not working the way I want, all values in 'classes' remain 0. Where am I messing this up? Thanks.
a = rand(10);
b = rand(10);
c = 1:49;
c = flipud(reshape(c,[7 7])');
edges = linspace(0,1,7);
d = discretize(a,edges);
e = discretize(b,edges);
classes = zeros(size(a));
for i = 1:7
for j = 1:7
classes(a == i & b == j) = c(i,j);
end
end

採用された回答

Elin Jacobs
Elin Jacobs 2022 年 12 月 9 日
I found my error,
it should be classes(d = i & e = j ) = c(i,j)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeJava Package Integration についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by