How can I insert my mathematical formula?

296 Views Asked by At

equation

I need to write above equation to my Matlab code but while writing it I got confused. M0=1.695, tetha1=41.31 degree, and gamma=1.4.

When I insert those numbers the result is M1=2.5476, but it should be around 1.51. Would you please write that code in Matlab?

I will insert my code also;

M1 = sqrt((2.4^2*M0^4*(sind(t1)^2)-4*(M0^2*(sind(t1)^2)-1)*(1.4*M0^2*(sind(t1)^2)+1))/((2.8*M0^2*(sind(t1)^2)-2.4)*(0.4*M0^2*(sind(t1)^2)+2))); 
1

There are 1 best solutions below

1
Gray_Rhino On

I rewrote you function in Matlab and for your given values (gamma=1.4, M0=1.695, tetha1=41.31) I am getting the same values. Here's the code:

function y = m1(g, M0, t1) % Do not edit this line.

  numarator = ((g+1)^2)*(M0^4)*(sind(t1)^2) - 4*((M0^2)*(sind(t1)^2)-1)*(g*(M0^2)*(sind(t1)^2)+1)
  denominator = (2*g*(M0^2)*(sind(t1)^2)-(g+1))*((g-1)*(M0^2)*(sind(t1)^2)+2)
  y = sqrt(numarator/denominator)

end % Do not edit this line.

Calling the function with given values:

m1(1.4, 1.695, 41.31)

gives:

numarator =

   17.9440


denominator =

    2.7648


y =

    2.5476


ans =

    2.5476