Having a string call another string

Hello everyone,
I'm new to matlab and learning it right now.
I was wondering how I would make a string that would prompt the user for an input statement and would output the statment exactly as shown (Your string was: 'hi there').
Enter your string: hi there
Your string was: ‘hi there’
Here is what I have so far and i've tried multiple different ways and cant seem to figure out how to call it back.
txt = input('Enter your string: ',"s");

回答 (1 件)

Stephen23
Stephen23 2024 年 6 月 17 日
移動済み: dpb 2024 年 6 月 17 日

1 投票

txt = input("Enter your string: ","s");
disp("Your string was: " + txt)

2 件のコメント

Zachary
Zachary 2024 年 6 月 17 日
移動済み: Stephen23 2024 年 6 月 17 日
Thank you so much!
Stephen23
Stephen23 2024 年 6 月 17 日
@Zachary: please remember to click the accept button for answers that helped you!

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

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

リリース

R2024a

タグ

質問済み:

2024 年 6 月 17 日

コメント済み:

2024 年 6 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by