How to reset typing in loop input if is Negative?

1 visualización (últimos 30 días)
Emilia
Emilia el 13 de Dic. de 2020
Respondida: Walter Roberson el 13 de Dic. de 2020
Hello,
I want to make a typo refund if there is a user error with negative. For example if a user types negative then the output will return the same as original.
Thanks for the helpers
clc;
clear;
v=input('Insert poisson ratio:'); %Poisson's ratio
if isempty(v) || (v<=0)
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Dic. de 2020
while true
v = input('Insert poisson ratio: '); %Poisson's ratio
if isnumeric(v) && isscalar(v) && v >= 0
break
end
end

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by