i need to error check this code
SkaDan = 'what are you looking for today? skating or dance\n';
Ans = input(SkaDan,'s');
i need it to move on if it spelled correct but if its not then i need it to spit out the message "ERROR, what are you looking for today? skating or dance"

 採用された回答

Image Analyst
Image Analyst 2022 年 5 月 3 日

0 投票

Here's one way:
replyOK = false;
SkaDan = 'What are you looking for today? Skating or dance?\n';
while ~replyOK
reply = input(SkaDan, 's');
if strcmpi(reply, 'skating') || strcmpi(reply, 'dance')
replyOK = true; % or "break" to break out of loop
end
end

1 件のコメント

Riley Phillips
Riley Phillips 2022 年 5 月 3 日
it works!! thank you so much!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Animation についてさらに検索

製品

リリース

R2021b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by