Unrecognized function or variable 'x'.

1 次查看(过去 30 天)
Maria
Maria 2023-11-16
编辑: Maria 2023-11-17
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 个评论
Maria
Maria 2023-11-16
编辑:Maria 2023-11-17
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 2023-11-16
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 = 

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2023-11-16
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];

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by