MATLAB Answers

Two equations of two unknown angles

조회 수: 69(최근 30일)
If I have:
A = 87; B = 65; C = 73; D = 92;
And the two equations are:
How do I write a code to find x and y?
What is the solution to this error?
  댓글 수: 2
Ravichandar Nalukurthy
Thank you, however I still get the invalid expression error.

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

채택된 답변

John D'Errico
John D'Errico 23 Feb 2021
편집: John D'Errico 23 Feb 2021
First, I would recognize that you PROBABLY intended 200 to be a number in DEGREES, not radians. (200 radians would seem to make little sense.) Therefore, you need to use sind and cosd, not sin and cos.
Since you know how to use solve, (sort of) I'll do it that way.
syms x y
A = 87; B = 65; C = 73; D = 92;
E1 = D*sind(200)+A*sind(x)+B*sind(y) == 0
E1 = 
E2 = 73+D*cosd(200)+A*cosd(x)+B*cosd(y) == 0
E2 = 
As you can see, sind and cosd convert the problem internally into one in radians. The x and y solutions will still be in the form of degrees though.
[xsol,ysol] = solve(E1,E2,x,y)
xsol = 
ysol = 
ans = 
ans = 
These will be angles in degrees, since I used sind and cosd. There are two primary solutions, but there are infinitely many solutions. We could add integer multiples of 360 degrees to those solutions.
  댓글 수: 1
Ravichandar Nalukurthy
Thank you for the help!!!

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

추가 답변(1개)

David Hill
David Hill 23 Feb 2021
fun = @solution;
x0 = [0,0];
I = fsolve(fun,x0);%solution
function f = solution(x)
  댓글 수: 1
Ravichandar Nalukurthy
Thank you for the help !!!

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

Community Treasure Hunt

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

Start Hunting!

Translated by