I have a system of 5 equations to solve which are originally in symbolic form
eqnA = m_s - ((A_sy*P_e)/sqrt(T_e))*sqrt(gamma/R)*M_sy*((1 + ((gamma-1)/2)*M_sy^2)^(-(gamma+1)/(2*(gamma-1))))*eta_s == 0;
eqnB = m_p - ((A_py*P_g)/sqrt(T_g))*sqrt(gamma/R)*M_py*((1 + ((gamma-1)/2)*M_py^2)^(-(gamma+1)/(2*(gamma-1))))*eta_s - m_p == 0;
eqnC = A_py + A_sy - A_3 == 0;
eqnD = P_g/P_c - (1 + (gamma-1)/2*M_py^2)^(gamma/(gamma-1)) == 0;
eqnE = P_e/P_c - (1 + (gamma-1)/2*M_sy^2)^(gamma/(gamma-1))== 0;
I also have known values
val_m_p = 0.3745, val_m_s = 0.1175, val_T_g = 298.0124, val_T_e = 298.0001, val_A_3 = 1.767*10^-4, val_P_e = 4.0000e+06, val_P_g = 5.1e+06
I substituted these values into the equations above, converted the equations into a function handle and proceeded to solve for the remaining 5 unknown variables
eqnAx = subs(eqnA, {P_e, T_e, m_s}, {val_P_e, val_T_e, val_m_s})
eqnBx = subs(eqnB, {P_g, T_g, m_p}, {val_P_g, val_T_g, val_m_p})
eqnCx = subs(eqnC, A_3, val_A_3)
eqnDx = subs(eqnD, P_g, val_P_g)
eqnEx = subs(eqnE, P_e, val_P_e)
g = matlabFunction([eqnAx; eqnBx; eqnCx; eqnDx; eqnEx])
options = optimset('Display','off');
x = fsolve(g, [0 0 0 0 0], options)
With g being
g =
function_handle with value:
@(A_py,A_sy,M_py,M_sy,P_c)[sqrt(7.0).*7.576938695805846e+1.*2.965820800757861e+6.*5.119801572077356e+7.*A_sy.*M_sy.*1.0./(M_sy.^2./5.0+1.0).^3.*(-4.518723221790994e-13)+1.174896374819055e-1==0.0;sqrt(7.0).*7.576938695805846e+1.*2.965820800757861e+6.*5.119907258219913e+7.*A_py.*M_py.*1.0./(M_py.^2./5.0+1.0).^3.*(-5.761966781546089e-13)==0.0;A_py+A_sy-1.767e-4==0.0;5.100744432356854e+6./P_c-(M_py.^2./5.0+1.0).^(7.0./2.0)==0.0;4.000005838383844e+6./P_c-(M_sy.^2./5.0+1.0).^(7.0./2.0)==0.0]
However, I had error message
Not enough input arguments.
Error in
symengine>@(A_py,A_sy,M_py,M_sy,P_c)[sqrt(7.0).*7.576938695805846e+1.*2.965820800757861e+6.*5.119801572077356e+7.*A_sy.*M_sy.*1.0./(M_sy.^2./5.0+1.0).^3.*(-4.518723221790994e-13)+1.174896374819055e-1==0.0;sqrt(7.0).*7.576938695805846e+1.*2.965820800757861e+6.*5.119907258219913e+7.*A_py.*M_py.*1.0./(M_py.^2./5.0+1.0).^3.*(-5.761966781546089e-13)==0.0;A_py+A_sy-1.767e-4==0.0;5.100744432356854e+6./P_c-(M_py.^2./5.0+1.0).^(7.0./2.0)==0.0;4.000005838383844e+6./P_c-(M_sy.^2./5.0+1.0).^(7.0./2.0)==0.0]
Error in fsolve (line 248)
fuser = feval(funfcn{3},x,varargin{:});
Error in Untitled10 (line 158)
x = fsolve(g, [0 0 0 0 0], options)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
I'm not too sure where it went wrong since the number of initialization parameters is the same as the number of unknowns. Please help:(
0 Comments
Sign in to comment.