Fsolve function with values read from the workspace
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kamal kiki
am 11 Feb. 2012
Beantwortet: Victor Hugo Cantú
am 25 Mär. 2019
we all know that we use an m-file with the system of non-linear equations that we want to solve with Fsolve. I want the m-file that I have to use with Fsolve in order to solve the following system of non linear equations.
A.x^p1+2*y^2-5*x+7*y-40=0
3*x^2-y^2+4*x+B*y^p2-28=0
where x and y are the unknowns that must be given by the solution and A,B,p1 and p2 are values that must be read from the workspace.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 11 Feb. 2012
xy0 = [1,1]; %initial guess
eqn = @(xy) [A .* xy(1).^p1 + 2 .* xy(2).^2 - 5 .* xy(1) + 7 * y(2) - 40, 3 .* xy(1).^2 - xy(2).^2 + 4 .* xy(1) + B .* xy(2).^p2 - 28];
xy = fsolve(eqn, xy0);
Weitere Antworten (2)
Victor Hugo Cantú
am 25 Mär. 2019
A = 1; B = 2; p1 = 2; p2 = 1;
guess = [2 3];
% x(1) = x; x(2) = y;
x = fsolve(@(x) trial(x,A,B,p1,p2), guess)
function F = trial(x,A,B,p1,p2)
F(1) = A*x(1)^p1 + 2*x(2)^2 - 5*x(1) + 7*x(2) - 40;
F(2) = 3*x(1)^2 - x(2)^2 + 4*x(1) + B*x(2)^p2 - 28;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!