Solve returning root but doesn't give a numerical expression.
49 次查看(过去 30 天)
显示 更早的评论
Hello ! I'm actually using the function " solve ", but instead of returning an expression, i get the following : "
9
root(z^4 - (10*z^3)/9 - z^2/6561 - z/729 - 91/6561, z, 1)
root(z^4 - (10*z^3)/9 - z^2/6561 - z/729 - 91/6561, z, 2)
root(z^4 - (10*z^3)/9 - z^2/6561 - z/729 - 91/6561, z, 3)
root(z^4 - (10*z^3)/9 - z^2/6561 - z/729 - 91/6561, z, 4)
These are indeed the solutions, but why it doesn't express it ? If i use the function " roots " with a vector with the above coefficient, it gives me the solution numerically. Anyone have a way to either get the answer numerically, or to extract the coeffcient of the above expression automatically ? In any case, here is the simple code :
clear all
syms a
b=9;h=0.1;
t2=a^4*b^3-b-h*(b^3-b^5*a^4)-(b^4*a^3-a-h*(a^3-b^4*a^5))
sol=solve(t2,a)
Thanks !
0 个评论
采纳的回答
Walter Roberson
2016-4-28
sol = solve(t2, a, 'MaxDegree', 4)
You should consider the possibility that you are using the wrong tool. solve() is for finding exact solutions. Your h is a floating point number rather than being 1/sym(10), which suggests that you are not interested in exact solutions. You should be giving consideration to using vpasolve() instead of solve()
更多回答(1 个)
pepe
2019-12-23
I have had a similar version dependent exprience. My code is:
syms x
solve(x^3+x-1==0)
In Matlab 2019 it produces the useless root() output that you also mentioned. But in MATLAB 2014 it produces a nicer result comprised of fractions and sums of numbers;...so I recommend you also give it a try using an old version of MATLAB.
good luck
پویا پاکاریان
پویاپاکاریان
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!