Borrar filtros
Borrar filtros

Matrix in an equation

2 visualizaciones (últimos 30 días)
Konstantina Vaitsi
Konstantina Vaitsi el 12 de Mayo de 2020
Editada: Konstantina Vaitsi el 12 de Mayo de 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

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by