Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How to include a second loop in my script

1 Ansicht (letzte 30 Tage)
Konstantina Vaitsi
Konstantina Vaitsi am 14 Mai 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 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 Kommentar
Rik
Rik am 14 Mai 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.

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by