フィルターのクリア

Matrix in an equation

2 ビュー (過去 30 日間)
Konstantina Vaitsi
Konstantina Vaitsi 2020 年 5 月 12 日
編集済み: Konstantina Vaitsi 2020 年 5 月 12 日
I have written this script and it works ok because all the cells in CLN0 are 50. But what if each cell was different? How could I write that?
The equation is CLN(B(i,j)<5) = CLN0(i,j) - 0.5*B(i,j)
Also how do I include the CLN matrixes in the loop so that every new CLN matrix is calculated upon the previous one?
S = [12 4 6 4;16 12 2 3;0 4 10 12;4 12 21 3]
CLN0 = 50*ones(4)
i = 1:4;
j = 1:4;
for t = 0:4
B = [S(i,j)- 2*t];
B(B<0)=0
CLN = zeros(size(B));
CLN(B(i,j)<5) = 50 - 0.5*B(i,j)(B(i,j)<5);
CLN(B(i,j)>=5) = 50 + 0.5*B(i,j)(B(i,j)>=5);
CLN(50 - 0.5*B(i,j)<0) = 0(50 - 0.5*B(i,j)<0)
endfor

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by