why use symbolic variables over others

3 ビュー (過去 30 日間)
Caolan Dix
Caolan Dix 2017 年 1 月 17 日
編集済み: Jyotish Robin 2017 年 1 月 20 日
Hello I am new to matlab and am working through a book by Huei Huang Lee called Programming with Matlab 2016. In his examples he declares variables and uses them. Then proceeds to declare variables as syms and uses those with no clear explanation as to why I would choose one over the other, which is better, etc. ...
e.g.: syms v0
vs.
v0=5.0
I checked the documentation and there didn't seem to be much there either.
Can anyone shed some light on this please?
Thank you! -Caolan

回答 (1 件)

Jyotish Robin
Jyotish Robin 2017 年 1 月 20 日
編集済み: Jyotish Robin 2017 年 1 月 20 日
Symbolic numbers are exact representations, unlike floating-point numbers.You can create symbolic numbers by using "sym". The symbolic number is represented in exact rational form, while the floating-point number is a decimal approximation. The symbolic result is not indented, while the standard MATLAB result is indented.
For example:
>>sym(1/3) %returns exact representation
1/3
>>1/3 %returns approximation
.3333
Here the symbolic number is represented in exact rational form, while the floating-point number is a decimal approximation. The symbolic result is not indented, while the standard MATLAB result is indented.
To get an overview of symbolic and numeric arithmetic, refer below link:
Hope it helps!!
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 1 月 20 日
You can have symbolic decimal numbers that are not represented as rationals.
Jyotish Robin
Jyotish Robin 2017 年 1 月 20 日
Yea. That statement was specific to the example I mentioned. I will edit. Thank you for pointing out. :)

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by