Matlab Does not divide two number in my project !

48 views (last 30 days)
Hi , I am doing a project . I use some Symbolic variable in my project . When I determine a matrix Matlab does not calculate division ! what should I do ?
B_rho =
[ 0, 0, 0, -1]
[6960476620317683/9007199254740992 , 4800328703667367/2251799813685248, 8352571944381219/18014398509481984, -5136351712924083/9007199254740992]
[ Rho, 0, 0, 0]
[ 1, 2/5, -2/5, -1]

Answers (2)

Star Strider
Star Strider on 20 Jul 2015
Use the vpa function.
For example:
M = [6960476620317683/9007199254740992 , 4800328703667367/2251799813685248, 8352571944381219/18014398509481984, -5136351712924083/9007199254740992];
M = vpa(M, 5)
M =
[ 0.77277, 2.1318, 0.46366, -0.57025]
  3 Comments
Star Strider
Star Strider on 20 Jul 2015
It works. It’s just that with a combination of numeric and symbolic terms, it looks a bit cumbersome.
It also wasn’t the problem you posted in your Question.
You will likely have to experiment with various functions to simplify your expression.
Steven Lord
Steven Lord on 20 Jul 2015
If you want to see a number as the result of that expression, you will need to substitute (using the SUBS function) a value for the variable Beta.

Sign in to comment.


Walter Roberson
Walter Roberson on 20 Jul 2015
When you use the symbolic engine then by default every number is converted to rational form, the same as the sym() 'r' option. You can explicitly designated one of the other options for any given number by using sym() with an option. For example if you currently have
syms x
b = x^(2/3)
then although the 2/3 will be calculated in MATLAB outside of the symbolic engine, the default 'r' conversion will notice that the 0.66666666 is 2/3 and will convert the expression to
b = sym(x^(sym(2)/sym(3))
If you want something else you can specify it:
b = x^sym(2/3,'d')
for example.
When you look through your char_poly(1,1) notice that the numbers that have not been converted to decimal are the exponents. That is because x^(8/5) does not mean the same thing as x^1.4, especially in the presence of negative values. The characteristic polynomial for a matrix allows for multiple roots but raising a number to a floating point power defines exactly one root, using the formula x^y = exp(y*ln(x)) .

Community Treasure Hunt

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

Start Hunting!