Clear Filters
Clear Filters

if,elseif ,else statements

1 view (last 30 days)
VASUNDHARA V
VASUNDHARA V on 26 Feb 2022
Edited: Jan on 26 Feb 2022
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 Comment
VASUNDHARA V
VASUNDHARA V on 26 Feb 2022
ok i got it ..initially i gave i=1:2 ...i have to initialize upto 9

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!