How to display both values and text as output

Hey MATLAB users,
I'm trying to show a numerical value with its unit in the command window. For example, 500 grams or 4.7k Ohms. Any suggestions?
Quick replies are much appreciated, thanks.

1 件のコメント

Stephen23
Stephen23 2016 年 2 月 12 日
How are the units stored? Do you have a separate string or cell array of strings?

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

回答 (1 件)

KSSV
KSSV 2016 年 2 月 12 日
編集済み: KSSV 2016 年 2 月 12 日

1 投票

w = 500 ;
R = 4.7 ;
fprintf('%f grams or %f k Ohms',w,R)

カテゴリ

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

タグ

質問済み:

2016 年 2 月 12 日

編集済み:

2016 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by