if,elseif ,else statements

1 次查看(过去 30 天)
VASUNDHARA V
VASUNDHARA V 2022-2-26
编辑: Jan 2022-2-26
I dnt know what is wrong with my code ..it only prints value upti i==2 then it ends ..i step by step checked it.
for i=1:2
if i==1
d(1,[1,2])=0
d(7,[1,2])=0
d(11,[1,2])=0
elseif i==2
d(9,[1,2])=0
elseif i==3
d(3,[1,2])=0
elseif i==4
d(2,[1,2])=0
d(5,[1,2])=0
elseif i==5
d(7,[1,2])=0
d(11,[1,2])=0
elseif i==6
d(9,[1,2])=0
elseif i==7
d(4,[1,2])=0
d(5,[1,2])=0
elseif i==8
d(8,[1,2])=0
d(9,[1,2])=0
else
if i==9
d(11,[1,2])=0
end
end
  1 个评论
VASUNDHARA V
VASUNDHARA V 2022-2-26
ok i got it ..initially i gave i=1:2 ...i have to initialize upto 9

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by