MATLAB: How to fprint a particular element corresponding to other element

fprint a particular element

I need to solve for a M value, so I created an array of M values, one of which is the correct M. The M is imbedded multiple times in a function. I know my function has to equal 1.2. Once I ran the code I had had many solutions in an matrix, I was able to find an answer close to 1.2. My question is, is there a way I can directly fprint what M I used to acquire the correct answer.
%%Constants
r = 1.4;
rm1 = r-1;
rp1 = r+1;
%%Process
M=[1:.01:3]
A_AS=sqrt((1./M.^2).*(((2+rm1.*M.^2)/rp1).^(rp1/rm1)));
Po2_Po1=((rp1*.5*M.^2)./(1+(rm1*.5*M.^2))).^(r/rm1).*(1./(((2*r)/rp1).*M.^2-(rm1/rp1))).^(1/rm1)
Ac_At=A_AS.*Po2_Po1
I would appreciate the help, thank you for your time.

Best Answer

[~, idx] = min(abs(Ac_at - 1.2));
M(idx)
By the way, exact solution is
temp = sqrt(roots([15593, -72030, 56595, -16660, 2415, -174, 5]));
temp(imag(temp)~=0) = [];
temp(temp < 1 | temp > 3) = [];
M = temp