How to solve for a trigonometric equation
2 views (last 30 days)
Show older comments
I want to solve for x from the following equation;
0.7978 + 0.7978*tan^2(x) = (Hperson * (1 - 0.1591*tan^2(x)))/ Fdist
The Hperson and Fdist are known values or variables. For example if Hperson = 175, Fdist = 120. The x value returned should be approx 38.7 degrees.
Apologies if such a question has been answered before. But I couldnt find a solution. Thank you.
0 Comments
Accepted Answer
Star Strider
on 18 Aug 2017
Rearrange the equation, then use fzero:
Hperson = 175;
Fdist = 120;
F = @(x) 0.7978 + 0.7978*tand(x).^2 - (Hperson * (1 - 0.1591*tand(x).^2)) / Fdist; % Create Implicit Expression
x_deg = fzero(F, 45) % Use ‘fzero’
x_deg =
38.69
2 Comments
Star Strider
on 18 Aug 2017
The fzero function solves the implicit version of your equation for ‘x’. ‘F’ and ‘G’ in your code are anonymous functions that fzero finds the root of that are nearest the initial estimate (if a real root exists in that region).
You have not provided a definition for ‘Hcamera’ in your function, and you have not passed it to your function as a parameter. Since you apparently want to solve for ‘Hcamera’, use fzero again, with an appropriate initial value:
Hc0 = 100;
Hcamera = fzero(G, Hc0);
and using your previous data for ‘Hperson’ and ‘Fdist’:
Hcamera =
211.55
More Answers (0)
See Also
Categories
Find more on Matrix Computations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!