How to display both values and text as output

99 Ansichten (letzte 30 Tage)
Denis Taiwo
Denis Taiwo am 12 Feb. 2016
Bearbeitet: KSSV am 12 Feb. 2016
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 Kommentar
Stephen23
Stephen23 am 12 Feb. 2016
How are the units stored? Do you have a separate string or cell array of strings?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 12 Feb. 2016
Bearbeitet: KSSV am 12 Feb. 2016
w = 500 ;
R = 4.7 ;
fprintf('%f grams or %f k Ohms',w,R)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by