Solve Nonlinear Equations with MATLAB

  Рет қаралды 162,362

APMonitor.com

APMonitor.com

8 жыл бұрын

MATLAB solves nonlinear equations either symbolically or numerically with solvers such as "fsolve". This example demonstrates how to obtain a solution to sets of nonlinear equations.

Пікірлер: 68
@agihtiassalam8628
@agihtiassalam8628 5 жыл бұрын
as a beginer in MATLAB, your lectures are very helpful, short and very compact. keep it up ! thank you
@borislum1998
@borislum1998 6 жыл бұрын
you are good teacher, easy to follow
@enriquenieto100
@enriquenieto100 4 жыл бұрын
Thank you !!! Well and simply explained
@amrgaber4400
@amrgaber4400 2 жыл бұрын
Man I love you, I tried to solve some combustion equations using solve but got error then I tried your method with fsolve and worked❤️❤️
@apm
@apm 2 жыл бұрын
Thanks for the feedback. I'm glad it worked!
@davidtorres9922
@davidtorres9922 10 ай бұрын
Thank you men, you save me. Very useful video!!!
@hussain55019
@hussain55019 7 жыл бұрын
Love You Sir..
@kilziantoine9542
@kilziantoine9542 7 жыл бұрын
Hello, is it possible to add the constraints on z(1) and z(2) (or x & y ) in fsolve similarly to what you did in the solve function ?
@apm
@apm 7 жыл бұрын
I'd recommend fmincon for constrained solutions to nonlinear equations. See this page (example #2): apmonitor.com/che263/index.php/Main/MatlabOptimization
@apm
@apm 7 жыл бұрын
Fsolve can't handle inequalities. Fmincon is a good tool for constrained nonlinear programming.
@pamirkldis118
@pamirkldis118 4 жыл бұрын
thanks a lot, you are the best
@Reyarth100
@Reyarth100 7 жыл бұрын
I need to solve a system of parametric non linear equations. How can I do that? Thanks!
@apm
@apm 7 жыл бұрын
+Reyarth100, take a look at the nonlinear regression example here: apmonitor.com/che263/index.php/Main/MatlabDataRegression
@dsrabelo
@dsrabelo 8 жыл бұрын
thank you!
@albertbii5315
@albertbii5315 3 жыл бұрын
good explanation.
@erikbryson7353
@erikbryson7353 6 жыл бұрын
Thank you.
@aaaaaa6285
@aaaaaa6285 4 жыл бұрын
How to solve a system of 10 nonlinear equation with 10 variables, having parameters that must be calculated by another function and imported?
@apm
@apm 4 жыл бұрын
You can have any number of variables and equations with this approach. apmonitor.com/che263/index.php/Main/MatlabSolveEquations You may also want to look at Gekko if you need to solve a large-scale problem (10,000+ variables) apmonitor.com/che263/index.php/Main/MatlabCallsPython
@ebeb9156
@ebeb9156 3 жыл бұрын
Very nice, thank u
@onyiboemmanuel6060
@onyiboemmanuel6060 3 жыл бұрын
Thanks a lot Sir
@AdrianaCastilloC
@AdrianaCastilloC 4 жыл бұрын
Thank you sooo much!
@jossiaradasilvabarbosa3537
@jossiaradasilvabarbosa3537 6 жыл бұрын
Thank you
@hojoduurenbileg5681
@hojoduurenbileg5681 7 жыл бұрын
Could you explain why you don't give the Myfunctions function any arguments when you put it into the fsolve.
@rrc
@rrc 7 жыл бұрын
At 6:05, the fsolve function only needs two inputs. They are the function handle (or string name) and the initial guesses (second argument). If you have optional input arguments that are not accessible to fsolve to change then you'll pass those in with the anonymous function such as fsolve(@(z)myFunction(z,optional_args),zg). If you don't have any optional arguments then you can just leave off the input arguments because fsolve knows that the inputs should be the same size as zg (the guess values).
@hojoduurenbileg5681
@hojoduurenbileg5681 7 жыл бұрын
Oh alright. Thanks.
@kapilgadhave2432
@kapilgadhave2432 8 жыл бұрын
thanks
@witsqafa
@witsqafa 7 жыл бұрын
how to solve the root 2 with 4 iteration and the starting point is also define?
@apm
@apm 7 жыл бұрын
+Witsqa Fadhilah, for finding the roots to a polynomial, I'd suggest the polyroot function. If you need to code it yourself, a Newton's method should work.
@saddamhussainsoomro2810
@saddamhussainsoomro2810 4 жыл бұрын
sir can you help me to solve 12 non linear equations with 12 variables, or guide anything please. Thanks
@apm
@apm 4 жыл бұрын
Check out APM MATLAB or Python Gekko. They can solve these problems. You can also find tutorials at apmonitor.github.io/data_science/
@samianina6636
@samianina6636 2 жыл бұрын
Hi saddam, I have a similar task here. I have to solve 16 non linear equations with 16 unknowns using lsqnonlin in Matlab (my variables are constrained) could you please advice how did you solve for yours? Thanks.
@ram.4152
@ram.4152 2 жыл бұрын
How to solve a system of non linear equations with different constant values that is read from a Csv file
@apm
@apm 2 жыл бұрын
Here is information on reading data from a CSV file: apmonitor.com/che263/index.php/Main/PythonDataAnalysis and solving nonlinear equations: apmonitor.com/pds/notebooks/10_solve_equations.html The syntax for MATLAB is similar, but you could also try it in Python.
@muhammadaaqibrabbani777
@muhammadaaqibrabbani777 2 жыл бұрын
Sir could it solve for an unkown constant like c instead of 9?
@apm
@apm 2 жыл бұрын
Yes, it isn't a problem if c has a value. If you need a symbolic solution then there is a symbolic toolbox. Otherwise, here is a symbolic tutorial in Python: github.com/APMonitor/data_science/blob/master/10.%20Solve_Equations.ipynb
@WytseZ
@WytseZ 5 жыл бұрын
Thanks for the explanation, very clear! Possible improvement for your video; Use some de-essing software because it is very painful to listen now
@apm
@apm 5 жыл бұрын
Thanks for the suggestion. I did upgrade my microphone a couple years ago and that has greatly helped the sound quality.
@WytseZ
@WytseZ 5 жыл бұрын
@@apm Good to know!
@arpitamondal5110
@arpitamondal5110 2 жыл бұрын
i wanted to solve 2 coupled nonlinear equations but i'm getting "equation solved , solver stalled". could you help me out?
@apm
@apm 2 жыл бұрын
Here is some help for solving differential equations: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@arpitamondal5110
@arpitamondal5110 2 жыл бұрын
@@apm thanks but i cant handle ......"Equation solved, solver stalled. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared and the vector of function values is near zero as measured by the value of the function tolerance." how can i fix this?
@apm
@apm 2 жыл бұрын
@@arpitamondal5110 it appears that the solver reaches an area that is causing a problem but that the solver nearly reached a solution. One suggestion is to try a better initial guess. You can also try a different solver when you use Python Gekko or Python fsolve: apmonitor.com/che263/index.php/Main/PythonSolveEquations One advantage of Python gekko is that you can add additional information such as an objective function (m.Minimize(x)) to create a unique solution if the problem has degenerate equations or additional degrees of freedom. You can also specify constraints with Gekko to help the solver avoid problem areas.
@arpitamondal5110
@arpitamondal5110 2 жыл бұрын
@@apm thanks a lot 🙂...I'll try
@khaoulabriki4220
@khaoulabriki4220 5 жыл бұрын
Thank you it is very helpful . if you can make a video to solve a nonlinear boundary equation ex:q = x''[t] + x'[t] + x[t] + x[t]^3;
@apm
@apm 5 жыл бұрын
Here is some course content on second order systems: apmonitor.com/che436/index.php/Main/LectureNotes20 or apmonitor.com/pdc/index.php/Main/SecondOrderSystems
@khaoulabriki4220
@khaoulabriki4220 5 жыл бұрын
APMonitor.com Thank you very much
@adchrisrob
@adchrisrob 5 жыл бұрын
U DA REAL MVP
@apm
@apm 5 жыл бұрын
Thxs!
@danielcachafeiro2590
@danielcachafeiro2590 2 жыл бұрын
Shouldnt you get as many roots as grades the polynomials are?
@apm
@apm 2 жыл бұрын
Numerical methods typically only get one solution and it depends on the starting guess value.
@ikhsanerlingga
@ikhsanerlingga 4 жыл бұрын
What does the equal sign mean?
@apm
@apm 4 жыл бұрын
The equal sign means that it is an equality constraint where the expression on the left side must equal the expression on the right side. Does that answer your question?
@user-qe6xd9oc5p
@user-qe6xd9oc5p 3 жыл бұрын
Do I have to write that x is greater than zeor
@apm
@apm 3 жыл бұрын
You need to use an optimizer to add constraints. apmonitor.com/che263/index.php/Main/MatlabOptimization
@SaqrThabet
@SaqrThabet 5 жыл бұрын
that was an impeccable lesson, but [x,y]=solve([x^2+y^2 = = 20,y = = x^2],x>0,y>0,[x,y]) did not work properly with me. However [x,y]=solve('x^2+y^2=20', 'y=x^2', ,'x>0' , 'y>0' ) did work just fine.
@apm
@apm 5 жыл бұрын
Thanks for posting your solution. There was an update to the package in a later version. From the documentation: www.mathworks.com/help/symbolic/solve.html : Character vector inputs have been removed. Instead, use syms to declare variables and replace inputs such as solve('2*x == 1','x') with solve(2*x == 1,x).
@chinnychin0135
@chinnychin0135 3 жыл бұрын
how do you split the z?
@apm
@apm 3 жыл бұрын
It shows how to do that at 6:22 It is x=z(1) and y=z(2)
@rebekah3632
@rebekah3632 Жыл бұрын
how is x>0 ?
@apm
@apm Жыл бұрын
That is one of the constraints on the variable.
@mannobilli458
@mannobilli458 7 жыл бұрын
how we solve z=sinx in matlab plz reply me soon
@apm
@apm 7 жыл бұрын
+Manno Billi, I don't think I understand your question. You can type something like z=sin(3.14) or you can plot the sine function with x=linspace(0,6.28) plot (x,sin(x)) Let me know if you have a more specific question.
@mannobilli458
@mannobilli458 7 жыл бұрын
use matlab to to make calculations if x=10 and y=3 solve z=sinx this is question written in textbook i want to how we write these calculations in matlab
@apm
@apm 7 жыл бұрын
Hummm...the question still doesn't make sense. There appear to be two given values (x and y) that are either fixed parameters or else guess values. I'm not sure what "z" is in this case. Here is the best way that I can interpret you question. Let me know if this isn't what you are asking. Perhaps you are asking if y = sin(x) and y=0, determine the value of x. The solution is with fsolve as: fsolve(@sin,0.1) or with cosine: fsolve(@cos,0.1) The 0.1 value is a guess value. The solution to the first one is 0.0 and the solution to the second one is pi/2 (although additional solutions exist. There is no solution if y = 3 because sin(x) cannot be higher than +1.0.
@mannobilli458
@mannobilli458 7 жыл бұрын
suppose that x=-7-5i and y=4+3i.use matlab to compute x/y
@apm
@apm 7 жыл бұрын
Here are some commands: x = -7 -5*i y = 4+3*i x/y Are these homework problems?
@SebasTian-xx6yc
@SebasTian-xx6yc 5 жыл бұрын
who were from engineering computations 2019
@apm
@apm 5 жыл бұрын
Check out apmonitor.com/che263 for more recent tutorials.
Solve Linear Equations with Python
7:46
APMonitor.com
Рет қаралды 106 М.
The basics of fsolve
12:49
Dr Gregory Reeves
Рет қаралды 19 М.
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 11 МЛН
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 46 МЛН
MATLAB Nonlinear Optimization with fmincon
14:26
APMonitor.com
Рет қаралды 238 М.
Solving Equations with MATLAB using fsolve
21:17
purdueMET
Рет қаралды 7 М.
How to fit non-linear equations in excel using solver
6:24
Taylor Sparks
Рет қаралды 250 М.
Non-Linear Simultaneous Equations - GCSE Higher Maths
15:23
1st Class Maths
Рет қаралды 26 М.
Using fsolve to solve non-linear equations
11:38
Dr Gregory Reeves
Рет қаралды 47 М.
Linear versus Nonlinear Differential Equations
7:18
The Math Sorcerer
Рет қаралды 275 М.
После ввода кода - протирайте панель
0:18
Up Your Brains
Рет қаралды 1 МЛН
Неразрушаемый смартфон
1:00
Status
Рет қаралды 2,4 МЛН
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 25 МЛН