フィルターのクリア

How to deal with white spaces?

2 ビュー (過去 30 日間)
Aaron Zorzi
Aaron Zorzi 2015 年 10 月 6 日
コメント済み: Aaron Zorzi 2015 年 10 月 6 日
I'm writing a little code just for fun, but I ran into a problem. The input is meant to ask the user what they would like to do, and the valid responses involve things such as 'PICK UP BOOK', 'OPEN DOOR', etc., which would then display the appropriate remark.
action_1 = input('What will you do?','s');
if action_1 == OPEN DOOR
display('stuff goes here')
Now you can see the problem, which is that I can't have white spaces in there. Is there a workaround for this, or would I have to separate the actions into parts that are more simple?

採用された回答

Thorsten
Thorsten 2015 年 10 月 6 日
if strcmp(action1, 'OPEN DOOR')
display('stuff goes here')
end
  1 件のコメント
Aaron Zorzi
Aaron Zorzi 2015 年 10 月 6 日
Thanks!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by