MATLAB help (finding all the possible values for x)?

Hi, I'm new to MATLAB,
I need to find all the possible values for x knowing that:
0<x<10
and
1.8*cos(1.8*x)+1.2*cos(1.2*x)=0
the only thing that works is
>> evalin(symengine, 'numeric::solve(1.8*cos(1.8*x)+1.2*cos(1.2*x)=0, x = 0..10)')
ans =
1.0057538744094438603875879163721
but it only gives one of the possible answers.
I should be getting
x≈
1.00575
2.97903
4.6645
5.80748
7.49295
9.46622
thanks

 채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 9월 5일

1 개 추천

syms x
x = solve(1.8*cos(1.8*x)+1.2*cos(1.2*x))
This gave me the analytical solution.
A more feasible way would be to solve this numerically using MATLAB:
x = fsolve(@(x)1.8*cos(1.8*x)+1.2*cos(1.2*x),10*rand(1))
Each time you run this you will get one of the different results. The second argument asks FSOLVE to start solving from a different start point.

추가 답변 (1개)

Roger Stafford
Roger Stafford 2013년 9월 5일

0 개 추천

Another approach is to expand both cosines in terms of cos(.6*x) which gives a cubic equation in the quantity. Any of its roots which are real and between -1 and +1 will give you an arccosine equation from which you can find all the solutions in the range you state.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by