I have two equations and I am trying to solve them by (fsolve) and (solve) but I did not get the expecting results!

5 visualizzazioni (ultimi 30 giorni)
kv=127.67;
kh=94.91;
M=0.53;
MU0=4*3.14e-7;
Mc=(3*MU0*M^2)/(2*pi);
eqn1=kv*xe-Mc*(1/(d+xe)^4)+Mc*((5*ye^2)/(2*(d+xe)^6))==0;
eqn2=kh*ye-Mc*ye*(1/(d+xe)^5)+Mc*ye*((5*ye^2)/(2*(d+xe)^7))==0;
%Need values of xe and ye

Risposte (1)

Simran
Simran il 3 Apr 2025
Hello @Qais Qaseem,
I see that you’re trying to solve two non-linear equations to find the values of “xe” and “ye” using “fsolve” and “solve”. You can follow these steps to do so:
Using fsolve:
1.) Start by defining all the constants. Then define a function that calculates the residuals of the equations.
2.) Since it is “fsolve” function, provide an initial guess for the variables.
initial_guess = [0.1, 0.1]; % Adjust based on your problem context
3.) You can use “optimoptions” to configure the solver’s behavior, such as displaying iteration details.
4.) Call the “fsolve” function to find solution.
5.) Retrieve the solution from “fsolve”.
I got this solution from following the above steps:
Using “solve”:
  1. Now unlike numerical solvers, “solve” works with symbolic mathematics, allowing it to find exact solutions or expressions.
  2. Start by defining all constants that are part of your equations.
  3. Use “syms” to declare “xe” and “ye” as symbolic variables.
  4. Write your equations symbolically and call the “solve” to find all the solutions to the system of equations.
  5. Convert the symbolic solutions to numerical form using double.
  6. Iterate over the solutions and display each pair.
This is the result I got for this:
You can refer to these documentation links for more help:

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by