Azzera filtri
Azzera filtri

why use symbolic variables over others

1 visualizzazione (ultimi 30 giorni)
Caolan Dix
Caolan Dix il 17 Gen 2017
Modificato: Jyotish Robin il 20 Gen 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

Risposte (1)

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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by