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
@agihtiassalam86285 жыл бұрын
as a beginer in MATLAB, your lectures are very helpful, short and very compact. keep it up ! thank you
@borislum19986 жыл бұрын
you are good teacher, easy to follow
@enriquenieto1004 жыл бұрын
Thank you !!! Well and simply explained
@amrgaber44002 жыл бұрын
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❤️❤️
@apm2 жыл бұрын
Thanks for the feedback. I'm glad it worked!
@davidtorres992210 ай бұрын
Thank you men, you save me. Very useful video!!!
@hussain550197 жыл бұрын
Love You Sir..
@kilziantoine95427 жыл бұрын
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 ?
@apm7 жыл бұрын
I'd recommend fmincon for constrained solutions to nonlinear equations. See this page (example #2): apmonitor.com/che263/index.php/Main/MatlabOptimization
@apm7 жыл бұрын
Fsolve can't handle inequalities. Fmincon is a good tool for constrained nonlinear programming.
@pamirkldis1184 жыл бұрын
thanks a lot, you are the best
@Reyarth1007 жыл бұрын
I need to solve a system of parametric non linear equations. How can I do that? Thanks!
@apm7 жыл бұрын
+Reyarth100, take a look at the nonlinear regression example here: apmonitor.com/che263/index.php/Main/MatlabDataRegression
@dsrabelo8 жыл бұрын
thank you!
@albertbii53153 жыл бұрын
good explanation.
@erikbryson73536 жыл бұрын
Thank you.
@aaaaaa62854 жыл бұрын
How to solve a system of 10 nonlinear equation with 10 variables, having parameters that must be calculated by another function and imported?
@apm4 жыл бұрын
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
@ebeb91563 жыл бұрын
Very nice, thank u
@onyiboemmanuel60603 жыл бұрын
Thanks a lot Sir
@AdrianaCastilloC4 жыл бұрын
Thank you sooo much!
@jossiaradasilvabarbosa35376 жыл бұрын
Thank you
@hojoduurenbileg56817 жыл бұрын
Could you explain why you don't give the Myfunctions function any arguments when you put it into the fsolve.
@rrc7 жыл бұрын
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).
@hojoduurenbileg56817 жыл бұрын
Oh alright. Thanks.
@kapilgadhave24328 жыл бұрын
thanks
@witsqafa7 жыл бұрын
how to solve the root 2 with 4 iteration and the starting point is also define?
@apm7 жыл бұрын
+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.
@saddamhussainsoomro28104 жыл бұрын
sir can you help me to solve 12 non linear equations with 12 variables, or guide anything please. Thanks
@apm4 жыл бұрын
Check out APM MATLAB or Python Gekko. They can solve these problems. You can also find tutorials at apmonitor.github.io/data_science/
@samianina66362 жыл бұрын
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.41522 жыл бұрын
How to solve a system of non linear equations with different constant values that is read from a Csv file
@apm2 жыл бұрын
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.
@muhammadaaqibrabbani7772 жыл бұрын
Sir could it solve for an unkown constant like c instead of 9?
@apm2 жыл бұрын
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
@WytseZ5 жыл бұрын
Thanks for the explanation, very clear! Possible improvement for your video; Use some de-essing software because it is very painful to listen now
@apm5 жыл бұрын
Thanks for the suggestion. I did upgrade my microphone a couple years ago and that has greatly helped the sound quality.
@WytseZ5 жыл бұрын
@@apm Good to know!
@arpitamondal51102 жыл бұрын
i wanted to solve 2 coupled nonlinear equations but i'm getting "equation solved , solver stalled". could you help me out?
@apm2 жыл бұрын
Here is some help for solving differential equations: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@arpitamondal51102 жыл бұрын
@@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?
@apm2 жыл бұрын
@@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.
@arpitamondal51102 жыл бұрын
@@apm thanks a lot 🙂...I'll try
@khaoulabriki42205 жыл бұрын
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;
@apm5 жыл бұрын
Here is some course content on second order systems: apmonitor.com/che436/index.php/Main/LectureNotes20 or apmonitor.com/pdc/index.php/Main/SecondOrderSystems
@khaoulabriki42205 жыл бұрын
APMonitor.com Thank you very much
@adchrisrob5 жыл бұрын
U DA REAL MVP
@apm5 жыл бұрын
Thxs!
@danielcachafeiro25902 жыл бұрын
Shouldnt you get as many roots as grades the polynomials are?
@apm2 жыл бұрын
Numerical methods typically only get one solution and it depends on the starting guess value.
@ikhsanerlingga4 жыл бұрын
What does the equal sign mean?
@apm4 жыл бұрын
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-qe6xd9oc5p3 жыл бұрын
Do I have to write that x is greater than zeor
@apm3 жыл бұрын
You need to use an optimizer to add constraints. apmonitor.com/che263/index.php/Main/MatlabOptimization
@SaqrThabet5 жыл бұрын
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.
@apm5 жыл бұрын
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).
@chinnychin01353 жыл бұрын
how do you split the z?
@apm3 жыл бұрын
It shows how to do that at 6:22 It is x=z(1) and y=z(2)
@rebekah3632 Жыл бұрын
how is x>0 ?
@apm Жыл бұрын
That is one of the constraints on the variable.
@mannobilli4587 жыл бұрын
how we solve z=sinx in matlab plz reply me soon
@apm7 жыл бұрын
+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.
@mannobilli4587 жыл бұрын
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
@apm7 жыл бұрын
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.
@mannobilli4587 жыл бұрын
suppose that x=-7-5i and y=4+3i.use matlab to compute x/y
@apm7 жыл бұрын
Here are some commands: x = -7 -5*i y = 4+3*i x/y Are these homework problems?
@SebasTian-xx6yc5 жыл бұрын
who were from engineering computations 2019
@apm5 жыл бұрын
Check out apmonitor.com/che263 for more recent tutorials.