Hi guys could you please help me in this if i could make loop like? I have attached m file too.

1 view (last 30 days)
for k=1:N
j=1
E_1=1;
while E_1>10^(-6)
j=j+1;
Calculate values;
Error=abs(calculated - assumed);
E_1=Error;
end
While
end
end
  5 Comments

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 9 Jan 2015
Daya - look at your while loop conditions
while E_11>Err
% etc.
while E_1>Err
% etc.
end
end
The E_11 and E_1 are initialized but are never reset. So if we enter either of these two loops because the condition is satisfied, then we will never exit the loop because neither of these two variables change, so that is why you are getting stuck. The last (or next to last) line of both while loops should be the re-initializaton of the variable that is being used in the condition. Try doing that and see what happens!

More Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!