필터 지우기
필터 지우기

Hello, How can i write divide by 4 micrometer ? code is attached below check the variable s. i am trying to plot frequency vs angular displacement.

조회 수: 2 (최근 30일)
filename = 'datacollect2.xlsx';
num = xlsread(filename);
rpm =num(: , 2);
time =num(: , 1);
N = length(num);
s=N/4*unit::\mum;
f=rpm/60;
a=s*sin(2*pi*f);
plot(f , a)

답변 (1개)

Walter Roberson
Walter Roberson 2017년 5월 22일
unit::\mum would be more of a syntax for use within the MuPAD symbolic engine, not in MATLAB itself. The MATLAB interface to it requires the Symbolic Toolbox, and would look like
u = symunit;
um = u.um;
s=N/(4*um);
However, this does not get you anything that you can plot directly. plot() does not know anything about units. To plot, you would need to remove the units from the values, using separateUnits(), and perhaps use findUnits() to detetermine the units. You can then convert the units to latex to use a a label, but there appears to be a trick to it:
a_units = findUnits(a);
latex(a_units) %gives '\left(\begin{array}{c} \mathrm{\mu m} \end{array}\right)'
latex(1*a_units) %gives '\mathrm{\mu m}'
... Basically, if you are only working with one unit and you are not required to carry units around due to coding standards, then it is a lot easier to just work numerically and attach the appropriate units later.

카테고리

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