Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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)

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Mayo de 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.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by