how to fprint a particular element corresponding to other element

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 15 Mar 2018
Modificato: Walter Roberson il 15 Mar 2018
[~, 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 Commenti
Walter Roberson
Walter Roberson il 16 Mar 2018
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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by