zeros of a multivariable function

조회 수: 13 (최근 30일)
Amir Ahmadi
Amir Ahmadi 2017년 11월 10일
편집: Walter Roberson 2017년 11월 10일
Hi
I am beginner in matlab, and I need two find two zeros of the following function.
I do not know how I can write its command, the function is:
syms x1 x2 x3 l a b g
% x1:= x, x2: = y, x3: = z, l: = lambda, a:= alpha, b:= beta, g:= damma
f(x1,x2,x3,l,a,b,g)=[-a*x1 - (x2)^2 - (x3)^2 + a*l,
-(x2) +(x1)*(x2) - b*(x1)*(x3) + g,
x3 + b*x1*x2 + x1*x3]
a = 0.25
b = 4
g = 0.5

답변 (2개)

Walter Roberson
Walter Roberson 2017년 11월 10일
편집: Walter Roberson 2017년 11월 10일
syms x1 x2 x3 l
a = 0.25
b = 4
g = 0.5
f = [-a*x1 - (x2)^2 - (x3)^2 + a*l,
-(x2) + (x1)*(x2) - b*(x1)*(x3) + g,
x3 + b*x1*x2 + x1*x3];
sol = solve(f, [x1, x2, x3]);
some_random_value_for_l = 1;
X1 = subs(sol.x1, l, some_random_value_for_l);
X2 = subs(sol.x2, l, some_random_value_for_l);
X3 = subs(sol.x3, l, some_random_value_for_l);
vpa([X1, X2, X3])
Now take any two of the five results. For more results, use a different value for some_random_value_for_l

Star Strider
Star Strider 2017년 11월 10일
Try this (requires the Optimization Toolbox):
syms x1 x2 x3 l a b g
a = 0.25;
b = 4;
g = 0.5;
% x1:= x, x2: = y, x3: = z, l: = lambda, a:= alpha, b:= beta, g:= damma
f(x1,x2,x3)=[(-a*x1 - (x2)^2 - (x3)^2 + a*l), (-(x2) +(x1)*(x2) - b*(x1)*(x3) + g), (x3 + b*x1*x2 + x1*x3)];
ff = matlabFunction(f, 'Vars',{[x1,x2,x3],l});
l = 1; % Supply The Correct Value For ‘l’
s = fsolve(@(in1) ff(in1,l), rand(1,3));

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by