i want to use while loop
1 次查看(过去 30 天)
显示 更早的评论
can anyone help to convert this code to the while loop :
n=5;
for i=1:n
for j=1:n
if i+j-1>n
H(i,j)=0;
else
H(i,j)=i+j-1;
end
end
end
H
0 个评论
采纳的回答
Sulaymon Eshkabilov
2023-1-6
Here is the version of your code with the [while... end] operation:
n=5;
i=1;
while i<=n
j=1;
while j<=n
if i+j-1>n
H(i,j)=0;
else
H(i,j)=i+j-1;
end
j=j+1;
end
i=i+1;
end
H
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!