Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to include a second loop in my script

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2020-5-14
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by