How to Stop MATLAB Program When Input Exceeds a Certain Value?

  • Context: MATLAB 
  • Thread starter Thread starter Hikarikaze
  • Start date Start date
  • Tags Tags
    Error Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
Hikarikaze
Messages
4
Reaction score
0
Hi there, I have a question about generating an error message in MATLAB..

say, A = input('Value of A = ')
if A > 5
disp ('Value of A is larger than 5')
else

end


So, question here is... How can I make the program stop once it finds out A is larger than 5 and returns to the previous command where it asks for the value of A so we can input a new value of A?
 
Physics news on Phys.org
You can put the whole process into a while loop. Search help in Matlab for the usage of while. There are lots of other good stuff on the internet also.