MATLAB POLYSPACE RELEASE NOTES User Manual Page 145

  • Download
  • Add to my manuals
  • Print
  • Page
    / 240
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 144
Flow Control
break
The bre ak statement lets you exit early from a for loop or while loop. In
nested loops,
break exits from the innermost loop only.
Here is an im provement on the example from the previous section. Why is
this use of
break a good idea?
a = 0; fa = -Inf;
b = 3; fb = Inf;
while b-a > ep s*b
x = (a+b)/2;
fx = x^3-2*x-5;
if fx == 0
break
elseif sign(fx) == sign(fa)
a = x; fa = fx;
else
b = x; fb = fx;
end
end
x
Error Control try, catch
This section covers those MATLAB functions that provide error handling
control.
try
The general form of a try-catch statement sequence is
try
statement
...
statement
catch
statement
...
statement
end
4-7
Page view 144
1 2 ... 140 141 142 143 144 145 146 147 148 149 150 ... 239 240

Comments to this Manuals

No comments