# symbolic vector to usual vector.

3 visualizzazioni (ultimi 30 giorni)
Marcos Hermosilla il 3 Dic 2017
Risposto: Karan Gill il 5 Dic 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.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

the cyclist il 3 Dic 2017
A quick search found this answer, which suggest that sym2poly and roots will do what you want.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Marcos Hermosilla il 3 Dic 2017
Thanks for encouraging that option, I had already tried that for g, but I never though on trying it for q, that seems to work, thanks.

Accedi per commentare.

### Più risposte (1)

Karan Gill il 5 Dic 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 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Calculus in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by