# Roots of Polynomials by loop in matlab

Tags:
1. May 6, 2015

Dear Friends! I need to find roots of polynomials with variable coefficients, The command I used is

w=0:50
A=w^2
B=w^3+2
C=w+2*w^2
D=w
E=w./2
ss=[A B C D E]
xi=roots(ss)
by this I find all the roots of equation,
I want to find velocities by setting
v1=w/xi(1)
v2=w/xi(2)
v3=w/xi(3)
v4=w/xi(4)
v5=w/xi(5)
and plot (w,v1)
the plot is straight line which is because the velocities i found is not the same as I need because of command xi(1). . . . I need list of values for v1, . . .

Can any one please guide me in syntax error I used...

2. May 6, 2015

### kreil

You need to use .^ to raise each element of w to the correct power. The ^ operator does matrix power if the operand is anything but a scalar (w is a vector).

Also, given that xi(n) is just a scalar root, what are you actually trying to calculate with v1,...,v5? Do you need to add in the power of x that is associated with each coefficient? Otherwise you'll always get a straight line since you're just dividing the numbers 1 through 50 (in vector w) by the scalar root (in xi(n)).

As an alternative, you can calculate these roots symbolically to get some expressions for the roots in terms of the coefficients.