필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to include a second loop in my script

조회 수: 1 (최근 30일)
Konstantina Vaitsi
Konstantina Vaitsi 2020년 5월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
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