Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to include a second loop in my script

1 visualización (últimos 30 días)
Konstantina Vaitsi
Konstantina Vaitsi el 14 de Mayo de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have created the following script and it works ok. However, I need to somehow include a second loop so that every Y matrix is calculated upon the previous one and not on the initial CLN matrix. For example, the first step gives Y = 56 for the first cell, so I want the second step to calculate Y = 56+0.5*B(i,j) and so on. Any suggestions? Thank you :)
S = [12 4 6 4;16 12 2 3;0 4 10 12;4 12 21 3];
CLN = 50*ones(4);
for t = 0:4
B = [S - 2*t];
B(B<0)=0
Y = zeros(size(B));
for i = 1:4
for j = 1:4
if (B(i,j)<5);
Y = CLN(i,j) - 0.5*B(i,j)
elseif(CLN(i,j)-0.5*B(i,j)<0)
Y = 0
else(B(i,j)>=5);
Y = CLN(i,j) + 0.5*B(i,j)
end
end
end
end
  1 comentario
Rik
Rik el 14 de Mayo de 2020
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by