# using fsolve function to solve for 2 unknowns

조회 수: 3(최근 30일)
Alexandra Justus 2021년 9월 15일
편집: Matt J 2021년 9월 15일
I am trying to use the fsolve funstion to solve for 2 unknowns, the3 and theta 4, and I am not sure how
in an .m file I have this:
function F = problem_one(theta)
theta3 = theta(1);
theta4 = theta(2);
f = (2*cosd(30)) + (7*cosd(theta3)) - (9*cosd(theta4)) -6;
g = (2*sind(30)) + (7*sind(theta3)) - (9*sind(theta4));
end
and in a different script file i have this:
x0 = [80,110];
sol = @fsolve[problem_one,x0];
it tells me that my problem_one variable in unrecognized, and also a failure in the inital function objective evaluation. Please help

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matt J 2021년 9월 15일
편집: Matt J 2021년 9월 15일
x0 = [80,110];
[sol, Fsol] = fsolve(@problem_one,x0),
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
sol = 1×2
88.8372 117.2861
Fsol = 1×2
1.0e+-6 * -0.3515 0.1394
function F = problem_one(theta)
theta3 = theta(1);
theta4 = theta(2);
F(1) = (2*cosd(30)) + (7*cosd(theta3)) - (9*cosd(theta4)) -6;
F(2) = (2*sind(30)) + (7*sind(theta3)) - (9*sind(theta4));
end

댓글을 달려면 로그인하십시오.

R2020a

### Community Treasure Hunt

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

Start Hunting!