-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtbm.m
More file actions
33 lines (31 loc) · 950 Bytes
/
tbm.m
File metadata and controls
33 lines (31 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [output] = tbm(m, angle, theta_flag)
% Solves Theta-Beta-Mach equation for Theta given M and Beta.
% With theta_flag == true, uses angle for Theta and
% solves numerically for Beta.
% Assume gamma = 1.4
g = 1.4;
s1 = sym("M");
s2 = sym("theta");
s3 = sym("beta");
s4 = sym("gamma");
eq = tan(s2) == 2*cot(s3)*(((s1^2)*(sin(s3)^2) - 1)/((s1^2)*(s4+cos(2*s3)) + 2));
if theta_flag == true
eq = subs(eq, [s1, s4, s2], [m, g, angle]);
res = vpasolve(eq, s3, [0 inf]);
while res > pi/2
res = res - (2*pi);
end
if res < 0
res = double(res + pi);
if res < 0
res = -1*res;
end
output = res;
else
output = res;
end
else
eq = subs(eq, [s1, s4, s3], [m, g, angle]);
output = double(solve(eq, s2));
end
end