Thresholding a value in matrix

25 ビュー (過去 30 日間)
ramdhan zakwan
ramdhan zakwan 2020 年 11 月 19 日
コメント済み: Rik 2022 年 11 月 17 日
I had been given a 8x8 matrix. How can I theshold a value in the matrix?
for example 100 or 255. Thank you.

採用された回答

Rik
Rik 2020 年 11 月 19 日
You can use the comparator operators to apply a threshold:
data=randi(200,8,8);
L= data<100; %L is true for all positions with a value below 100
data2=data;%make a copy
data2(L)=200 %edit only some values
data2 = 8×8
189 200 200 200 200 200 155 160 200 200 200 200 200 189 132 200 200 200 123 128 200 173 200 101 200 200 200 156 157 200 169 200 200 200 200 147 117 200 157 163 164 172 101 134 170 200 200 196 200 165 200 123 118 195 200 200 118 200 200 200 200 200 183 200
  3 件のコメント
Daniel Arturo
Daniel Arturo 2022 年 11 月 17 日
why is it data=randi(200,8,8) ?
Rik
Rik 2022 年 11 月 17 日
@Daniel Arturo That is how I generated an array with numbers of approximately the same data range as shown in the question. Because it was posted as an image I couldn't use the actual data without copying them all by hand. This command generates an 8x8 grid with random integers from 1 to 200.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by