Is it possible to stop or interrupt a code in MATLAB if a condition is reached and end the simulation of the program code ? -


is possible stop or interrupt code in matlab if condition reached , end simulation of program code ? eg have loop involves calculating parameter , moment value becomes complex no. code stop executing , return value of counter @ parameter value became complex.

yes, possible. if want exit script, can use this:

if complex(parameter)     disp(counter);     return; end 

if want exit function , return value of counter caller, can use this:

if complex(parameter)     return(counter) end 

if want break out of loop, use this:

for ...     if complex(parameter)         break;     end end print(counter) 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -