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 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Walter Roberson
on 22 May 2017
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 Comment
Walter Roberson
on 22 May 2017
(I just submitted a bug report about findUnits not returning the same datatype as units)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!