フィルターのクリア

How do I put a variable input inside a char vector?

1 回表示 (過去 30 日間)
TheSaint
TheSaint 2024 年 2 月 1 日
コメント済み: TheSaint 2024 年 2 月 2 日
fprintf('Car number' 'is driving the fastest', x)
I have this function, and I want to put an input command such as this in between 'Car number' and 'is driving...'
CarNumber = input('Please enter the car number')
Is there a way I can do this? I tried using this line below, but it was unsuccessful
fprintf('Car number'CarNumber 'is driving the fastest', x)

採用された回答

Voss
Voss 2024 年 2 月 1 日
CarNumber = input('Please enter the car number: ');
fprintf('Car number %d is driving the fastest\n', CarNumber);
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 2 月 1 日
Or
fprintf("Car number " + CarNumber + " is driving the fastest\n")
TheSaint
TheSaint 2024 年 2 月 2 日
Thanks Walter, this worked for me

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by