why use symbolic variables over others

3 views (last 30 days)
Caolan Dix
Caolan Dix on 17 Jan 2017
Edited: Jyotish Robin on 20 Jan 2017
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

Answers (1)

Jyotish Robin
Jyotish Robin on 20 Jan 2017
Edited: Jyotish Robin on 20 Jan 2017
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 Comments
Walter Roberson
Walter Roberson on 20 Jan 2017
You can have symbolic decimal numbers that are not represented as rationals.
Jyotish Robin
Jyotish Robin on 20 Jan 2017
Yea. That statement was specific to the example I mentioned. I will edit. Thank you for pointing out. :)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!