Clear Filters
Clear Filters

Matrix in an equation

2 views (last 30 days)
Konstantina Vaitsi
Konstantina Vaitsi on 12 May 2020
Edited: Konstantina Vaitsi on 12 May 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

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!