symbolic vector to usual vector.
3 views (last 30 days)
Show older comments
Marcos Hermosilla
on 3 Dec 2017
Answered: Karan Gill
on 5 Dec 2017
I have a 1xn sym array, it as symbolic numbers and 1 variable. little example:
g =
[ 1, (3*5^(1/2))/10, -(15*k)/29, -(27*5^(1/2)*((100*k)/261 - 370/2349))/200, (75*k^2)/1682 + (25*k)/522 + 9/232,...]
What I want to do is get this as a numerical polynomial in k, to find the roots.
One thing I tried was:
q=0;
for i=1:n
q=g(i)+q;
end
To get a symbolic expression that I can solve with
s=solve(q==0,k)
However, this only gives me the root(long expression,z,1) (4 roots, every root at the end changes the 1 for 2,3,4)
That's it, I want to solve for k.
Thanks in advance.
0 Comments
Accepted Answer
More Answers (1)
Karan Gill
on 5 Dec 2017
You don't need a loop to sum g. Just use sum. Then use vpasolve instead of solve to get numeric results. Easy.
>> syms k
>> g = [ 1, (3*5^(1/2))/10, -(15*k)/29, -(27*5^(1/2)*((100*k)/261 - 370/2349))/200, (75*k^2)/1682 + (25*k)/522 + 9/232]
g =
[ 1, (3*5^(1/2))/10, -(15*k)/29, -(27*5^(1/2)*((100*k)/261 - 370/2349))/200, (75*k^2)/1682 + (25*k)/522 + 9/232]
>> g = sum(g)
g =
(3*5^(1/2))/10 - (245*k)/522 + (75*k^2)/1682 - (27*5^(1/2)*((100*k)/261 - 370/2349))/200 + 241/232
>> gSol = vpasolve(g,k)
gSol =
4.655999784043073895594300397083
8.4637649957826080781662669845712
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!