MATLAB Answers

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

조회 수: 4(최근 30일)
Nishant Hinge
Nishant Hinge 2021년 7월 30일
편집: Walter Roberson 2021년 7월 31일
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
Walter Roberson
Walter Roberson 2021년 7월 31일
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.

댓글을 달려면 로그인하십시오.

답변(1개)

Walter Roberson
Walter Roberson 2021년 7월 30일
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.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by