MATLAB: How to define a while statement that when the variable equals a numerical value, ends the code

while condition

Hi,
I want to write a while condition that when variable A gets a numerical value inside the loop, ends the code, otherwise continues to the code…
How can I write this while condition?
Thansks in advance,
Regards…

Best Answer

while ~exist('A', 'var') && ~isnumeric(A)
...
end
This will continue to loop until A is assigned a value and the value is numeric.
The common kinds of values that are not numeric include logical values, character strings, structures, cell arrays, function handles, graphics objects (R2014b or later), and various other kinds of objects.
Related Question