フィルターのクリア

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.
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 5 月 22 日
(I just submitted a bug report about findUnits not returning the same datatype as units)

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by