MATLAB Roots of Polynomials by loop in matlab

Click For Summary
The discussion focuses on finding roots of polynomials with variable coefficients using MATLAB. The user attempts to compute velocities based on these roots but encounters issues with the syntax and the nature of the calculations. The command used to define polynomial coefficients is correct, but the user is advised to utilize the element-wise power operator (.^) instead of the matrix power operator (^) to ensure proper calculations across the vector w. Additionally, there is a concern about the calculation of velocities v1 through v5, as they are derived from scalar roots, which leads to a straight line in the plot. The discussion suggests that the user may need to incorporate the powers of x associated with each coefficient to achieve the desired results. An alternative approach is proposed, recommending the calculation of roots symbolically to derive expressions in terms of the coefficients.
adnan jahan
Messages
93
Reaction score
0
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 anyone please guide me in syntax error I used...
 
Physics news on Phys.org
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K