Can I create a symbolic variable with units and assign an initial value of 0
8 ビュー (過去 30 日間)
古いコメントを表示
G'day, new to Matlab and just been through symbolic equations tutorial.
If I do the following:
syms dia circ u
u=sysunit
dia=10*u.m %10 is assigned with the unit of a metre
If I then say
dia = 0
dia
0 %zero is returned with no units.
Can I assign units to a sym reqardless of quantity and have the units carry through all calculations?
That is, can I define dia and circ with the units of metre or kg etc without assigning a numeric value?
Thanks and reqards
Paul
0 件のコメント
回答 (4 件)
Priyanshu Mishra
2019 年 12 月 1 日
According to MATALAB documentation, you need to assign a value to speciy unit. For more information on symunit, you may refer to the following link
0 件のコメント
Walter Roberson
2019 年 12 月 5 日
Units are implemented by multiplying by a symbolic variable that can be recognized by the units manipulation package. Unfortunately because it is a multiplication, when the value being multiplied by is 0, the result simplifies to just 0 -- with no unit.
You have to use cell array representation to hold the units along with a value of 0. See the temperature 0 discussion at https://www.mathworks.com/help/symbolic/units-conversion.html
0 件のコメント
Paul Buckman
2019 年 12 月 6 日
1 件のコメント
Walter Roberson
2019 年 12 月 7 日
It is a nuisance that 0 acts this way, and I filed a bug report about it years ago. I do recommend that other people file as well, as Mathworks prioritizes problems that multiple people complain about.
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!