Filter löschen
Filter löschen

Matrix in an equation

2 Ansichten (letzte 30 Tage)
Konstantina Vaitsi
Konstantina Vaitsi am 12 Mai 2020
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

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by