フィルターのクリア

How to add an input to the end of an fprintf function

2 ビュー (過去 30 日間)
TheSaint
TheSaint 2024 年 2 月 3 日
コメント済み: Star Strider 2024 年 2 月 3 日
units = input('Please enter the units for your rectangular coordinates: ','s');
I have this line of code right here. I would like the user to enter the units, and then have them display after this line of code below:
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f)' , r, lambda, phi )
For example, if the units are in mm, I just need the code to read: (r , lambda, phi) mm
I tried using this code below, but it was unsuccessful.
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f)' , r, lambda, phi ) + units

採用された回答

Star Strider
Star Strider 2024 年 2 月 3 日
Perhaps this —
r = rand;
lambda = rand;
phi = rand;
units = 'mm';
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f) %s' , r, lambda, phi, units)
Our rectangular coordinates converted to cylindrical coordinates are (0.76,0.79,0.03) mm
.
  2 件のコメント
TheSaint
TheSaint 2024 年 2 月 3 日
Thank you!
Star Strider
Star Strider 2024 年 2 月 3 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by