Solve Equations in MATLAB

Main.MatlabSolveEquations History

Hide minor edits - Show changes to markup

June 21, 2020, at 04:12 AM by 136.36.211.159 -
Deleted lines 56-74:

(:html:)

 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

(:htmlend:)

October 16, 2019, at 01:53 PM by 173.117.144.240 -
Added lines 13-24:

Source Code

(:source lang=matlab:) clear all A = [3 -9; 2 4]; b = [-42; 2]; % three methods x = inv(A)*b % good x = A\b % better x = linsolve(A,b) % best (:sourceend:)

Changed line 31 from:

Source Code

to:

Source Code

Changed lines 21-24 from:
 % Create new file myFunction.m
 function F=myFunction(z)
   x = z(1);
   y = z(2);
to:

(:source lang=matlab:) % Create new file myFunction.m function F=myFunction(z)

  x = z(1);
  y = z(2);
Changed lines 27-37 from:
   F(1)=x^2+y^2-20;
   F(2)=y - x^2;
 end


 % Create new file mySolver.m
 clear all
 zGuess = [1; 1];
 z = fsolve(@myFunction, zGuess);
 disp(z)
to:
  F(1)=x^2+y^2-20;
  F(2)=y - x^2;

end (:sourceend:)

(:source lang=matlab:) % Create new file mySolver.m clear all zGuess = [1; 1]; z = fsolve(@myFunction, zGuess); disp(z) (:sourceend:)

Added lines 43-44:

The APMonitor Modeling Language with a MATLAB interface is optimization software for mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control. It is freely available through MATLAB, Python, Julia, or from a web browser interface.

Added lines 18-37:

Source Code

 % Create new file myFunction.m
 function F=myFunction(z)
   x = z(1);
   y = z(2);

   F(1)=x^2+y^2-20;
   F(2)=y - x^2;
 end


 % Create new file mySolver.m
 clear all
 zGuess = [1; 1];
 z = fsolve(@myFunction, zGuess);
 disp(z)

Additional Tutorials

Changed line 16 from:

<iframe width="560" height="315" src="https://www.youtube.com/embed/eafGnpct1Ro" frameborder="0" allowfullscreen></iframe>

to:

<iframe width="560" height="315" src="https://www.youtube.com/embed/bvsXzrE9r3o" frameborder="0" allowfullscreen></iframe>

Changed line 10 from:

<iframe width="560" height="315" src="https://www.youtube.com/embed/qpZUbXCVxSQ" frameborder="0" allowfullscreen></iframe>

to:

<iframe width="560" height="315" src="https://www.youtube.com/embed/-m6qtOrNPkQ" frameborder="0" allowfullscreen></iframe>

Added lines 1-38:

(:title Solve Equations in MATLAB:) (:keywords MATLAB, solve equations, linear, nonlinear:) (:description MATLAB tutorial on solving linear and nonlinear equations with matrix operations (linear) or symbolic solve MATLAB functions (nonlinear):)

The following tutorials are an introduction to solving linear and nonlinear equations with MATLAB. The solution to linear equations is through matrix operations while sets of nonlinear equations require a solver to numerically find a solution.

Solve Linear Equations with MATLAB

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/qpZUbXCVxSQ" frameborder="0" allowfullscreen></iframe> (:htmlend:)

Solve Nonlinear Equations with MATLAB

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/eafGnpct1Ro" frameborder="0" allowfullscreen></iframe> (:htmlend:)

Linear and nonlinear equations can also be solved with Excel and Python. Click on the appropriate link for additional information and source code.


(:html:)

 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

(:htmlend:)