Effacer les filtres
Effacer les filtres

Unrecognized function or variable 'x'.

1 vue (au cours des 30 derniers jours)
Maria
Maria le 16 Nov 2023
Modifié(e) : Maria le 17 Nov 2023
Hello.
I don’t understand why I don’t have x defined after running the code, if initially it says errors. Help me please
function F=M36(x)
F=[3*x(1)*x(2) - x(1)^2 - x(2)^2 - 5;
7*x(1)^2 * x(2)^2 - x(1)^4 - x(2)^4 - 155];
options = optimoptions('fsolve','Display','iter');
[~,~] = fsolve(F,[-4,0],options);
[~,~] = fsolve(F,[0,4],options);
disp('Plotting graphs of the left sides of the system equations:')
x=-5:0.1:5;
y= (3/2).*x+ sqrt((13/4).*x.^2+5);
plot(y,x,'b')
hold on
x=-5:0.1:5;
y = sqrt((x^4 + 155) / (7*x^2 - y^2));
plot(y,x,'b')
hold on
grid on
legend('Graphic solution');
end
  3 commentaires
Maria
Maria le 16 Nov 2023
Modifié(e) : Maria le 17 Nov 2023
I want to solve a system of nonlinear equations 3*x(1)*x(2) - x(1)^2 - x(2)^2 = 5;
7*x(1)^2 * x(2)^2 - x(1)^4 - x(2)^4 = 155 create a file - m using the extended function fzero, check the solution using the roots function, and also plot solutions
Walter Roberson
Walter Roberson le 16 Nov 2023
syms x [1 2]
eqns = [3*x(1)*x(2) - x(1)^2 - x(2)^2 == 5;
7*x(1)^2 * x(2)^2 - x(1)^4 - x(2)^4 == 155]
eqns = 
sol = solve(eqns)
sol = struct with fields:
x1: [4×1 sym] x2: [4×1 sym]
subs([x1, x2], sol)
ans = 

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 16 Nov 2023
F = @(x)[3*x(1)*x(2) - x(1)^2 - x(2)^2 - 5;
7*x(1)^2 * x(2)^2 - x(1)^4 - x(2)^4 - 155];

Community Treasure Hunt

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

Start Hunting!

Translated by