MATLAB: How to create an error message when invalid data is input and then prompt to re-enter the data

error messageMATLAB

person_age = input('Please enter persons age')
If person_age < 1
errordlg('Please input valid number','Error')
end
How do I display this error message and then prompt the user to re-enter the person_age?
Many thanks

Best Answer

person_age = input('Please enter persons age');
while person_age < 1
errordlg('Please input valid number','Error')
person_age = input('Please enter persons age');
end
Related Question