Roots of Polynomials by loop in matlab

Click For Summary
SUMMARY

The discussion focuses on finding roots of polynomials with variable coefficients in MATLAB using the command roots. The user initially attempts to compute velocities by dividing a vector w by the roots obtained, but encounters issues due to incorrect syntax and misunderstanding of MATLAB's operators. The solution involves using the element-wise power operator .^ instead of ^ for vector operations and clarifying the calculation of velocities based on the polynomial's coefficients.

PREREQUISITES
  • Familiarity with MATLAB syntax and commands
  • Understanding of polynomial roots and their significance
  • Knowledge of element-wise operations in MATLAB
  • Basic concepts of vector mathematics
NEXT STEPS
  • Learn about MATLAB's element-wise operations, specifically .^ and ./
  • Explore symbolic computation in MATLAB for polynomial roots
  • Research polynomial coefficient interpretation in velocity calculations
  • Study MATLAB plotting functions to visualize polynomial behaviors
USEFUL FOR

Mathematics students, MATLAB users, engineers working with polynomial equations, and anyone interested in numerical methods for root finding.

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 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K