Hey all, new here, lookin for some help with matlab, pretty much no experience.(adsbygoogle = window.adsbygoogle || []).push({});

Gotta solve a system of 29 non-linear equations so here is what i was thinkin. I made a m-file with func which has each "guess/starting point" set to a variable. Then this function puts all of these into a matrix just so its easier to change and move around etc. Then my other m-file (as shown) has all the equations. Dont know if you can take a matrix as "IN" or what im doin wrong but keeps thrown errors so any help would be much appreciated...thanks in advance (Also what is the syntax/code for fsolve once i get this workn)?

I had it set so i would call the other function, create a matrix with all those value and pass it to the one below (prolly not best most efficient but im not too good at all this)

function f = HWFive (A)

m1=A(1);

m2=A(2);

m8=A(3);

m10L=A(4);

m10V=A(5);

m14=A(6);

T2=A(7);

T4=A(8);

T5=A(9);

T6=A(10);

T7=A(11);

T10=A(12);

T12=A(13);

T13=A(14);

cp4=A(15);

cp13=A(16);

P4=A(17);

P13=A(18);

h5=A(19);

h6=A(20);

h6g=A(21);

h7=A(22);

h8=A(23);

h10L=A(24);

h10V=A(25);

h11=A(26);

h12=A(27);

mpropane=A(28);

methylene=A(29);

%Well Here It Goes.....

% T-Joint No.1

f(1) = m1-m2+m14;

f(2) = m1*290-m2*T2+m14*320;

%Compressor No.1

f(3) = (P4/1000)-7.5+150.5*((m2*T2^0.5)/1000);

%Propane Evaporator

f(4) = (230 - T4)/100 + exp((-2.64/(m2*cp4)));

f(5) = cp4-2.114-0.000188*P4+(1.76*10^-8)*P4^2;

%Heat Exchanger No.1

f(6) = m2*cp4*(T4-T5)-m14*cp13*(T13-T12);

f(7) = ((T13 - T12)/(T4 - T12)) - ((1 - exp((-4.22/(m14*cp13)*(1 - ((cp13*m14)/(cp4*m2))))))/(1 - ((cp13*m14)/(cp4*m2))*exp((-4.22/(m14*cp13)*(1 - ((cp13*m14)/(cp4*m2)))))));

f(8) = cp13 - 2.114 - 0.000188*P13 + (1.76*10^(-8))*(P13)^2;

%Compressor No.2

f(9) = (1000/P13) - 5.6 + ((142.8*m14*T13^0.5)/P13);

%Heat Exchanger No.2

f(10) = m2*(h6 - h7) - m14*(h12 - h11);

f(11) = 1 - exp((-5.275*(T6 - T7))/(m2*(h6 - h7))) - ((T6 - T7)/(T6 - T12));

f(12) = h6 + 219.6 - 7.025*T6 + (0.034965*(T6)^2) - (0.00011321*(T6^3));

f(13) = h7 + 219.6 - 7.025*T7 + (0.034965*(T7)^2) - (0.00011321*(T7^3));

f(14) = h12 - 790.13 + 4.0137*T12 - (0.058268*(T12)^2) + (0.00019465*(T12^3));

f(15) = log(P13) + (1026/T12) - 13.8;

%Storage Tank

f(16) = m10L + m10V - m8;

f(17) = m8*h8 - m10L*h10L - m10V*h10V;

f(18) = h10L + 219.6 - 7.025*T10 + (0.034965*(T10^2)) - (0.00011321*(T10^3));

f(19) = h10V - 790.13 + 4.0137*T10 - (0.058268*(T10^2)) + (0.00019465*(T10^3));

f(20) = log(101) + (1026/T10) - 13.8;

%T-Joint No.2

f(21) = m2 - m14 - m8;

f(22) = h11 - h7;

f(23) = h8 - h7;

%Ethylene Evaporator

f(24) = m2*(h5 - h6) - 42.2*(T6 - 170);

f(25) = h5 - h6g - cp4*(T5 - T6);

f(26) = h6g - 790.13 + 4.0137*T6 - (0.058268*(T6^2)) + (0.00019465*(T6^3));

f(27) = log(P4) + (1026/T6) - 13.8;

%Other Mass Flow Rates

f(28) = (mpropane)*427.8 - (m2*cp4*(T2 - T4));

f(29) = (methylene)*800.1 - m2*(h5 - h6);

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab + fsolve Please Help

**Physics Forums | Science Articles, Homework Help, Discussion**