how to fprint a particular element corresponding to other element

1 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2018-3-15
编辑:Walter Roberson 2018-3-15
[~, 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
  3 个评论
Walter Roberson
Walter Roberson 2018-3-16
For r = 1.4 only, you are trying to solve
216*M^6*(1/(7*M^2-1))^(1/2)/((M^2+5)^(1/2)*(7*M^2-1)^2) == Value
where Value == 1.2 in your case.
This has a solution form of
RootOf((16807*Value^2-46656) * z^12 + 72030*Value^2 * z^10 -56595*Value^2 * z^8 + 16660*Value^2 * z^6 -2415*Value^2 * z^4 + 174*Value^2 * z^2 -5*Value^2, z)
where RootOf(f(z),z) stands for the set of values, z, such that f(z) is 0 -- the roots of the polynomial.
You can see that only even powers are used, so this can be reduced to +/- the square root of the roots of a degree 6 polynomial,
+/- sqrt( roots([(16807*Value^2-46656), 72030*Value^2, -56595*Value^2, 16660*Value^2, -2415*Value^2, 174*Value^2, -5*Value^2]) )
Again, Value here is the 1.2 that you are seeking.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by