Is It possible create a function that, given an equation, finds the value of the (x) so the two members are equal?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have the previous problem and consists in finding the values of (Mach) and (pp1). I thought to find then the values of (Mach) and (pp1) such that the two members of the equation are equal and I used the function "fsolve" but without acceptable results (I have insert my personal script and linked function). Is it possible use the construct "while"?
댓글 수: 3
dpb
2019년 5월 7일
Sorry, I ran out of time last night...didn't have chance to do anything -- but, one thing I notice that is problem in the NLFunctions1 routine -- you don't return a 2-vector of the the two equations--but only one.
See if
function F = NLfunctions1(x)
Ap1=20.4282
At=6.2458
gam=1.2
pg=0.604
%definizione funzioni
F(1) = (Ap1/At)^2 - ((1/(x(1))^2))*[(2/(gam+1))*(1+((gam-1)/(2)))(x(1))^(2))]^((gam+1)/(gam-1));
F(2) = ((pg)/(x(2)))-(1+(((gam-1)/(2))*x(1)^(2))^(gam/(gam-1)));
end
won't help...
답변 (1개)
David Goodmanson
2019년 5월 7일
Hi Gianmarco,
the two equations aren't coupled, and using fzero on Mp^2 seems to work. In the first equation I multiplied by both sides by Mp^2 and took both sides to the (gam-1)/(gam+1) power, so the variations in the functions are smaller and the search limits are easier to guess.
At=6.2458; % mm^2
Ap1=20.4282; % mm^2
pg=0.604; % Mpa
gam=1.2;
fun1 = @(m2) (m2*(Ap1/At)^2).^((gam-1)/(gam+1)); % left
fun2 = @(m2) (2/(gam+1))*(1+((gam-1)/2)*m2); % right
Mp2 = fzero(@(m2) fun1(m2)-fun2(m2), [.01 1])
pp1 = pg*(1+((gam-1)/2)*Mp2).^(-gam/(gam-1))
% check
(Ap1/At)^2 - (1/Mp2)*((2/(gam+1)*(1+((gam-1)/2)*Mp2))).^((gam+1)/(gam-1))
ans = 4.6185e-14
pg - pp1*(1+((gam-1)/2)*Mp2).^(gam/(gam-1))
ans = 0
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!