Solving trigonometric equation using "solve" function.

조회 수: 141 (최근 30일)
Biswajit Dipan Biswas
Biswajit Dipan Biswas 2019년 7월 2일
편집: Torsten 2023년 4월 15일
Hi,
I'm trying to solve trigonometric equation as follows,
230.769*cos(x) + 153.846*sin(x) =1.715.
For this, I'm using the matlab code,
syms x;
solve(230.769*cos(x)+153.846*sin(x) == 1.715, x, 'IgnoreProperties',true, 'ReturnConditions', true);
but, in the answer structure, I couldn't find the values. The ans.x field shows that it hase 2 symbols, but there isn't any value inside them. Can you please help to find what is wrong?
Thank you.

채택된 답변

John D'Errico
John D'Errico 2019년 7월 2일
편집: John D'Errico 2019년 7월 2일
Whats the problem? There is no need to set any properties anyway on such a trivial problem.
syms x;
x = solve(230.769*cos(x)+153.846*sin(x) == 1.715, x);
vpa(x)
ans =
2.1526153643152832650062014581097
- 0.97661015722014818434287396730445 - 1.8367099231598242312011508394098e-40i
The second solution is real, it just has an infinitesimal imaginary part.
And of course, you can add any multiple of 2*pi to those solutions.
But even if you do as you did, then LOOK AT THE SOLUTION THAT YOU DID GET. THINK ABOUT IT!
xsol = solve(230.769*cos(x)+153.846*sin(x) == 1.715, x, 'IgnoreProperties',true, 'ReturnConditions', true)
xsol =
struct with fields:
x: [2×1 sym]
parameters: [1×1 sym]
conditions: [2×1 sym]
>> vpa(xsol.x)
ans =
6.283185307179586476925286766559*k + 2.1526153643152832650062014581097
6.283185307179586476925286766559*k - (0.97661015722014818434287396730445 + 1.8367099231598242312011508394098e-40i)
Which says that for integer k, you can add any integer multiple of 2*pi to the solution. I'm pretty sure I said that initially.
xsol.conditions
ans =
in(k, 'integer')
in(k, 'integer')
  댓글 수: 1
Biswajit Dipan Biswas
Biswajit Dipan Biswas 2019년 7월 3일
Thank you so much. I didn't know the application of vpa function. I appreciate your prompt help.

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

추가 답변 (1개)

Jaimin amin
Jaimin amin 2023년 4월 15일
sol=solve({-sin[t2+t3]-sin[t2]==-1.5 && cos[t2+t3]+cos[t2]==0.8660},{t2,t3})
  댓글 수: 2
Jaimin amin
Jaimin amin 2023년 4월 15일
to find t2 and t3
Torsten
Torsten 2023년 4월 15일
편집: Torsten 2023년 4월 15일
syms x y real
sol=solve([sin(x+y)+sin(x)==1.5,cos(x+y)+cos(x)==0.5*sqrt(3)],[x y])
sol = struct with fields:
x: [2×1 sym] y: [2×1 sym]
sol.x
ans = 
sol.y
ans = 

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by