I am trying to write a matlab code to solve for 13 equations with 13 unknowns. b
ID: 3575645 • Letter: I
Question
I am trying to write a matlab code to solve for 13 equations with 13 unknowns. below is the code.
function flow = myCredit (f1, hL1, Re1, v2, f2, hL2, Re2, hL, hpump, v1, vdot2, vdot, vdot1)
syms f1 hL1 Re1 v2 f2 hL2 Re2 hL hpump v1 vdot2 vdot vdot1
eq1 = 7000 == 998*vdot*9.81*hpump/0.68;
eq2 = hpump == 7 +hL;
eq3 = hL == hL1;
eq4 = hL == hL2;
eq5 = v1 == vdot1/(pi/4*0.03^2);
eq6 = v2 == vdot2/(pi/4*0.05^2);
eq7 = Re1 == 998*v1*0.03/(1.002*10^(-3));
eq8 = Re2 == 998*v2*0.05/(1.002*10^(-3));
eq9 = 1/sqrt(f1) == -2.0*log10(2.51/(Re1*sqrt(f1)));
eq10 = 1/sqrt(f2) == -2.0*log10(2.51/(Re2*sqrt(f2)));
eq11 = hL1 == f1*v1^2*25/0.5886;
eq12 = hL2 == f2*v2^2*25/0.981;
eq13 = vdot == vdot1+vdot2;
flow = solve(eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9, eq10, eq11, eq12, eq13, f1, hL1, Re1, v2, f2, hL2, Re2, hL, hpump, v1, vdot2, vdot, vdot1);
end
The answer i keep getting is:
ans =
f1: [1x1 sym]
hL1: [1x1 sym]
Re1: [1x1 sym]
v2: [1x1 sym]
f2: [1x1 sym]
hL2: [1x1 sym]
Re2: [1x1 sym]
hL: [1x1 sym]
hpump: [1x1 sym]
v1: [1x1 sym]
vdot2: [1x1 sym]
vdot: [1x1 sym]
vdot1: [1x1 sym]
But I want to return actual values. How can I fix this?
Explanation / Answer
function flow = myCredit (f1, hL1, Re1, v2, f2, hL2, Re2, hL, hpump, v1, vdot2, vdot, vdot1)
syms f1 hL1 Re1 v2 f2 hL2 Re2 hL hpump v1 vdot2 vdot vdot1
eq1 = 7000 == 998*vdot*9.81*hpump/0.68;
eq2 = hpump == 7+hL;
eq3 = hL == hL1;
eq4 = hL == hL2;
eq5 = v1 == vdot1/(pi/4*0.03^2);
eq6 = v2 == vdot2/(pi/4*0.05^2);
eq7 = Re1 == 998*v1*0.03/(1.002*10^(-3));
eq8 = Re2 == 998*v2*0.05/(1.002*10^(-3));
eq9 = 1/sqrt(f1) == -2.0*log10(2.51/(Re1*sqrt(f1)));
eq10 = 1/sqrt(f2) == -2.0*log10(2.51/(Re2*sqrt(f2)));
eq11 = hL1 == f1*v1^2*25/0.5886;
eq12 = hL2 == f2*v2^2*25/0.981;
eq13 = vdot == vdot1+vdot2;
flow = solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9, eq10, eq11, eq12, eq13] ,[f1, hL1, Re1, v2, f2, hL2, Re2, hL, hpump, v1, vdot2, vdot, vdot1]);
valuef1 = flow.f1
valuehL1 = flow.hL1
valueRe1 = flow.Re1
valuev2 = flow.v2
valuef2 = flow.f2
valuehL2 = flow.hL2
valueRe2 = flow.Re2
valuehL = flow.hL
valuehpump = flow.hpump
valuev1 = flow.v1
valuevdot2 = flow.vdot2
valuevdot = flow.vdot
valuevdot1 = flow.vdot1
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.