How to display units (micro, mili,mega..) automatically?

조회 수: 115 (최근 30일)
Hande
Hande 2012년 9월 24일
댓글: dipak 2022년 3월 11일
I want to show the values with units on the plot
For example, instead of 5.43e-006 sec , I want it to be seen 5.43 μsec.
Or instead of 0.00065 sec, 0.65 msec. Do you have any idea how can I do this?

답변 (2개)

Wayne King
Wayne King 2012년 9월 24일
Why don't you just scale the elements by the appropriate factor?
t = 0:1e-6:0.001;
x = cos(2*pi*1e5*t);
plot(t.*1e6,x)
xlabel('\musec')

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 24일
% look at this example
close
t0=10^(-8);
t=linspace(t0,t0*10,100)
y=sin(t/t0)
t1=t;tm=max(t1)
unit='s'
if tm<10^(-6)
t1=t*10^6
unit='t(\mus)'
elseif tm>10^(-6) & tm <10^-(3)
t1=t*10^3
unit='t(ms)'
end
plot(t1,y)
set(gca,'xtick',round(linspace(min(t1),max(t1),10)*100)/100)
xlabel(unit)
  댓글 수: 1
dipak
dipak 2022년 3월 11일
https://www.mathworks.com/matlabcentral/fileexchange/33174-number-to-scientific-prefix

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by