# Find X and Y using matlab

22 visualizzazioni (ultimi 30 giorni)
Adam Goza il 31 Ago 2017
Risposto: MSP il 31 Ago 2017
X=y^2 2y-x^2=-2
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (2)

Star Strider il 31 Ago 2017
Use fsolve and a bit of algebra:
f = @(x,y) [y.^2 - x; 2.*y-x.^2 + 2];
XY0 = [1; 1];
XY = fsolve(@(b) f(b(1),b(2)), XY0);
There are several solutions. Experiment with ‘XY0’ to find all of them.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

MSP il 31 Ago 2017
First you have to make a function like this in a certain directory
function F=eqn(k)
x=k(1);
y=k(2);
F(1)=y^2-x;
F(2)=2*y-x^2+2;
end
Name the function as eqn and save it
Then in that same directory(folder) run this coode from command window or a file if you want to.Make sure that the directory is same, If confused use
The code goes here
kl=[2;78] %imagine values of x and y to be any number
k=fsolve(@eqn,zg) %solve nonlinear function by this
x=k(1) %the first value returned is of x and the other of y as defined earlier in eqn function
y=k(2)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by