How to display both values and text as output

조회 수: 157 (최근 30일)
Denis Taiwo
Denis Taiwo 2016년 2월 12일
편집: KSSV 2016년 2월 12일
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일
w = 500 ;
R = 4.7 ;
fprintf('%f grams or %f k Ohms',w,R)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by