Tan/ cot angle return

조회 수: 6 (최근 30일)
Patrick Scott
Patrick Scott 2021년 3월 11일
답변: Pranav Verma 2021년 3월 15일
Is there a way to return both possible angles for the trig equations I used in vpasolve below?
%% Input Inital Conditions and Calculations Problem 2
gamma = 1.4;
M1 = 1.5; %Incoming Mach number
theta0 = 0.001*pi/180; %(inital guess for vpasolve)theta must be greater than zero for oblique shock
syms x
top = (M1^2*(sin(x)^2))-1;
bottom = (M1^2*(gamma + cos(2*x))) + 2;
eq1 = tan(theta0) == 2*cot(x*top/bottom);
beta = vpasolve(eq1,x, theta0); %beta in degrees
beta = double(beta) % Convert beta to a double
betaRad = beta*pi/180; %Beta in radians

답변 (1개)

Pranav Verma
Pranav Verma 2021년 3월 15일
Hi Patrick,
You can find other solutions by specifying the intial guess for other solutions. In your case, you can graph the LHS and RHS your equation,
eq1 = 2*cot(x*top/bottom) == tan(theta0);
to find out the intersecting points and specify the initial guess around those values where the graphs of LHS and RHS intersect each other.
Please refer to the example in the documentation where it is shown for the multiple solutions for the below equation:
% 200 * sin(x) = x^3 - 1
syms x
eqnLeft = 200*sin(x);
eqnRight = x^3 - 1;
fplot([eqnLeft eqnRight])
title([texlabel(eqnLeft) ' = ' texlabel(eqnRight)])
Hope it helps!
Thanks

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by