How should i solve a system of non-linear equations and then plot the interdependence of any two variables? Can i use vpasolve?

3 views (last 30 days)
I have a system of non-linear equations. Assume i have more than 10 variables. I have around 10-11 equations. I want the user to decide which two variables to select and then plot the interdependence of these two variables on a Y vs X graph (Y and X being those variables).
I have only been able to solve this system of equation using vpasolve
below is the sample of my code
prompt = 'enter a number'
z=input(prompt)
syms x y c
eq1 = x - z
eq2 = y - 3
eq3=(x^2)/y + (y^2)/x + c
eqz = [eq1,eq2,eq3]
[xs,ys,cs]=vpasolve(eqz,[x,y,c]);
plot(xs,cs);
  5 Comments
Nishant Hinge
Nishant Hinge on 31 Jul 2021
Dear sir, I am completely apologetic for the ambiguity of the question. Let's say I have a 3 variables, 2 parameters and 3 very complicated non linear equations which give me unique solution only when I specify both the 2 parameters. What I want to do is plot graph of any one variable vs a parameter of my choice. What I have done till now is find a unique solution for a unique set of parameter values using vpa solve. But my main objective is to plot a graph. Please help me if you could
Thanking you.
Walter Roberson
Walter Roberson on 31 Jul 2021
Edited: Walter Roberson on 31 Jul 2021
In that situation you cannot use vpasolve to return formulas in terms of the free variables -- with the exception that sometimes you can if the nonlinear equations can be expressed as multinationals of low degree.
You would probably need to assign definite values to the free variables, vpasolve, assign different values, vpasolve again, and so on. Or switch to a numeric solver using the same strategy of solving each combination individually.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 30 Jul 2021
If you have equations that have a finite number of solutions, then:
  • if the equations are multinationals then in theory matlab can find a form that expresses all of the solutions in terms of free variables. However in practice as the degree of the equations increases, it becomes more likely that matlab will return a solution that is difficult to work with. In this case you might be able to plot the results in terms of the free variables.
  • if the equations are modified multinationals that involve rational but non-integer powers, then in theory matlab can find all of the solutions, but it is common for the results to be in a form that is difficult to use. There is a chance that you might be able to plot the results in terms of the free variables but most often it is not possible in this case.
  • if the equations involve periodic or quasi-periodic functions such as bessel functions, then matlab is probably not going to be able to express the infinite set of solutions. In a situation like this, matlab will find at most one solution and will have to give definite values to the free variables to do so. Plotting in terms of the free variables would require sweeping over definite values for the variables and asking for one numeric solution at a time
  • sufficiently complicated nonlinear but non-periodic functions are beyond the ability of MATLAB to find general solutions for, and again all you could do is put in definite values for the free variables and solve one combination at a time and plot later.
So multinational, maximum degree 4, you might be able to do what you want. Sometimes with more complicated systems. But in general, No.

Categories

Find more on Get Started with Symbolic Math Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!