MATLAB: How to exit a program or rather not process further code if a condition is not met abort programif statement Say for example a check for a variable 'a' ? If a is not equal to (a~= 1) abort the program and do not execute further codes , else continue ? Thanks, Tonu Best Answer Error should only be used when there is, ehm, an error. To stop the execution otherwise, use return. Related SolutionsMATLAB: Exit function early and return output Assign the desired value to the output variable. Then use return MATLAB: Looping until conditions met Wouldn't that just beif abs(f(y)) < 0.0001 break;endYou shouldn't be using == to compare floating point values anyway. Particularly, if one of them come out as a result of a calculation. Related QuestionIs there a way to abort the code inside a functionLoop iteration with condition met
Best Answer