Finding Roots of an Equation in MATLAB

  • MATLAB
  • Thread starter adnan jahan
  • Start date
  • Tags
    Matlab Roots
In summary, the individual is seeking help in finding the roots of a polynomial equation in MATLAB, with the requirement of four non-repeating roots. Two options are presented, with the second option being the preferred solution. The conversation then shifts to a question about defining the vertical axis in a MATLAB plot command, with the solution being to use the set() function.
  • #1
adnan jahan
96
0
Dear Fellow,

I need to find the roots of equation
x^8- 2x^6+3x^4-7x^2+a=0
in MATLAB, in such a way that I need 4 non repeating roots.

I have used the technique of
p=[1 -2 3 -7 1]
s=roots(p)
x1=s(1)
x2=s(2)
x3=s(3)
x4=s(4)
where xi,i=1,2,3,4 are roots of the above equation,

2nd option my friend gave me is

p=[1 -2 3 -7 1]
s=sqrt(roots(p))
x1=s(1)
x2=s(2)
x3=s(3)
x4=s(4)
this will again give me four roots of the equation,

need your help to find the four roots of above equation.


Regards
 
Physics news on Phys.org
  • #2
Clearly your polynomial is in x^2, so your friends solution is the correct one. Though you should of course use the plus and minus (+/-) of the roots.
 
  • #3
Okay ,,,, thanks uart,, that's really help full
 
  • #4
can you please give my any idea how to define vertical axis in MATLAB plot command

thanks
 
  • #5
adnan jahan said:
can you please give my any idea how to define vertical axis in MATLAB plot command

thanks

it's automatically designated by your data set, but you can also set particular properties of the axis with (for example):

set(gca,'YTick',[0 0.05 0.075 0.1 0.15 0.2 0.25])

and you could even go as far as to label each of the points:

set(gca,'YTickLabel','0|0.05|Cutoff|0.1|0.15|0.2|0.25')

full documentation:
http://www.mathworks.com/help/techdoc/creating_plots/f1-19798.html
 
Last edited by a moderator:

What is the purpose of finding roots of an equation in MATLAB?

The purpose of finding roots of an equation in MATLAB is to determine the values of the independent variable that make the equation equal to zero. This is useful in solving various mathematical problems, such as finding the solutions to a system of linear equations or determining the maximum or minimum points of a function.

How do I find the roots of an equation in MATLAB?

To find the roots of an equation in MATLAB, you can use the built-in function roots(). This function takes in the coefficients of the equation as its input and returns the values of the roots as its output. You can also use the graphical method by plotting the equation and identifying the points where it crosses the x-axis, which represent the roots.

What if my equation has multiple roots?

If your equation has multiple roots, the roots() function will return all the distinct values of the roots. If there are repeated roots, they will be returned as a single value with a corresponding multiplicity. You can also use the polyval() function to evaluate the equation at specific points and identify the roots by finding where the output is equal to zero.

Can I find complex roots of an equation in MATLAB?

Yes, you can find complex roots of an equation in MATLAB. The roots() function can handle complex coefficients and will return the complex roots as its output. You can also use the complex() function to convert the real coefficients of an equation to complex numbers before using the roots() function.

Are there any limitations to finding roots of an equation in MATLAB?

Yes, there are some limitations to finding roots of an equation in MATLAB. The roots() function may not be able to find all the roots for certain types of equations, such as higher degree polynomials or equations with multiple variables. In these cases, you may need to use other methods or techniques to find the roots.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
993
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
121
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
825
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • Precalculus Mathematics Homework Help
Replies
13
Views
853
Back
Top