Constructing a Loop in Matlab to Solve Polynomial Equations

In summary, the conversation discusses the use of Matlab for solving polynomial equations. The speaker wants to create a loop that will substitute the answers from the first round back into the equations to produce multiple answers. They are advised to read about loop control keywords in the Matlab documentation to get started.
  • #1
jemma
36
0
Using Matlab, I have 4 polynomial equations which I can solve by substituting the starting values for the variables into the equations. However, I want to contruct a loop to then substitute the answer from the first round back into the equations to replace the orginal starting values, and do this multiple times to produce multiple answers (a different answer for every round in the loop). Any idea how I can do this? Thanks :)
 
Physics news on Phys.org
  • #2
Start by reading about the various loop control keywords. Here's a good place to start - http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/getstart.pdf. Section 4.2, Loop Control, should help you get going.
 

Related to Constructing a Loop in Matlab to Solve Polynomial Equations

1. What is a loop in Matlab?

A loop in Matlab is a programming structure that allows you to repeat a set of code multiple times. It is useful for performing repetitive tasks, such as solving polynomial equations with different inputs.

2. How do I construct a loop in Matlab?

To construct a loop in Matlab, you can use either the "for" or "while" loop syntax. The "for" loop will execute a set of statements for a specific number of times, while the "while" loop will continue to execute as long as a given condition is true.

3. How can I use a loop to solve polynomial equations in Matlab?

You can use a loop in Matlab to solve polynomial equations by first defining the equation as a function, and then using a loop to iterate through different input values. Within the loop, you can use the built-in "roots" function to find the roots of the polynomial equation.

4. Can I use a loop to solve polynomial equations with complex roots?

Yes, you can use a loop in Matlab to solve polynomial equations with complex roots. When using the "roots" function, you can specify the output as a complex number by using the "complex" keyword. Additionally, you can use the "real" and "imag" functions to separate the real and imaginary components of the complex roots.

5. Are there any limitations to using a loop to solve polynomial equations in Matlab?

While using a loop in Matlab to solve polynomial equations can be a useful approach, it may not be the most efficient method for complex or higher-degree equations. In these cases, it is recommended to use built-in functions specifically designed for solving polynomial equations, such as "polyval" or "polyroots".

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top