IF statement restarting when condition is true
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
andrea vironda
am 12 Mär. 2016
Bearbeitet: Rick Rosson
am 12 Mär. 2016
hello i make an IF statement:
d=input('Is this spur gear mounted between two bearing? (Y/N): ','s');
if d=='N'
error('this program is not for you');
elseif d~='Y' | d~='N'
disp('you must use capital letters')
return
end
i would, if the second condition is true, to restart the code from
d=input('...
how can i do this?
0 Kommentare
Akzeptierte Antwort
Rick Rosson
am 12 Mär. 2016
Bearbeitet: Rick Rosson
am 12 Mär. 2016
k = [];
while isempty(k)
d=input('Is this spur gear mounted between two bearing? (Y/N): ','s');
k = findstr(upper(d),'YN');
if isempty(k)
fprintf('Invalid response. Please try again.\n');
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!