Try something like this —
Gamma=1.4
Mu_2=MuM(2.2, Gamma,10);
M_2 = FindM_2(Mu_2,Gamma)
function [M_2]=FindM_2(Mu_2,Gamma)
Term_1=sqrt((Gamma+1)/(Gamma-1));
Inner = @(M_2) M_2^2-1;
Term_2 = @(M_2) sqrt(((Gamma-1)/(Gamma+1))*Inner(M_2));
Term_3 = @(M_2) sqrt(Inner(M_2));
equ = @(M_2) Mu_2 - Term_1*atan(Term_2(M_2))-atan(Term_3(M_2));
M_2 = fsolve(equ, 1)
end
function Mu_2=MuM(Mach, Gamma,Theta) % The first function finds Mu_1 which in turn finds Mu_2. This functions works fine
Term_1=sqrt((Gamma+1)/(Gamma-1));
Inner=Mach^2-1;
Term_2=sqrt(((Gamma-1)/(Gamma+1))*Inner);
Term_3=sqrt(Inner);
Mu_1=Term_1*atan(Term_2)-atan(Term_3);
Mu_1=rad2deg(Mu_1);
Mu_2=Mu_1+Theta;
end
This runs without error (after a fair bit of effort to get it this far), however the solution is several orders-of-magnitude differnt from the expected result. I defer to you to solve that.
The Symbolic Math Toolbox is likely inappropriate here, principallty because it is not intended for iterative applications, and so will be extremely slow. Note that instead of using it, this version of the code uses multiple anonymous functions. If you are not familiar with them, see Anonymous Functions for an extended discussion.
.