MATLAB: Can someone help me with this error. Error in TSDGroup_18 (line 42) te=x(1);

te=x(1)

function [val] = TSDGroup_18(x)
%UNKNOWN VALUES a function for the equations in problem 6.16 solving for following values in problem schematic %input parameter: x — vector ?%1 te evaporating temperature %2 tc condensing temperature %3 P power %4 taout temperature exiting a %5 tbout temperature exiting b %6 qe evaporator %7 qc condensor
%Define Knowns %Evaporator, converted from W/k to kW/K in order to keep units cohesive UA1= 31.0; %kW/K w1= 6.5; %kg/s
%Condensor, converted from W/k to kW/k in order to keep units cohesive UA2= 25.0; %kW/K w2= 7.5; %kg/s
%Specific Weight cp= 4.2; %kJ/kgK
%provided values for input temperature in degrees K %tain=[283.15 285.65 288.15] tain=10;
%provided values for input temperature in degrees K %tbin=[298.15 303.15] tbin= 30;
%EQUATIONS %1: Equation 1 %2: Equation 2 %3: Equation 3 %4: Equation 4 %5: Equation 5 %6: Equation 6 %7: Equation 7
te=x(1); tc=x(2); P=x(3); taout=x(4); tbout=x(5); qe=x(6); qc=x(7);
%Calculations and Gathered Equations
%Equation 1 (q condensor) val(1)= wb*cp*(tain-taout)-qc;
%Equation 2 (q evaporator) val(2)= wb*cp*(tbout-tbin)-qe;
%Equation 3 (balancing the problem schematic) val(3)=qe+P-qc;
%Equation 4 (curve fitting for P) val(4)=(-2.89415e-5*(tc^2) + 1.63078e-3*(tc) – 3.80394e-2)*(te^2)+(1.44295e-3*(tc^2) – 2.47310e-2*tc – 1.88758e-1)*(te)+(-8.99105e-3*(tc^2) + 1.94087e0*(tc)- 3.51076e1)-P;
%Equation 5 (curve fitting for qe) val(5)=(-1.96620e-4*(tc^2) + 2.08655e-2*(tc) – 3.56666e-1)*(te^2)+(3.51630e-3*(tc^2) – 4.42262e-1*(tc)+ 1.90407e1)*te+(-7.10395e-3*(tc^2)-4.84674e0*tc + 2.38256e2)-qe;
%Equation 6 val(6)=(tbin+(tc-tbin)*(1-exp*(-UAc/wb*Cp)))-tbout;
%Equation 7 val(7)=(tain+(te-tain)*(1-exp(-UAe/wa*Cp)))-taout;
fsolve(val,0)

Best Answer

x=1:7
val = TSDGroup_18(x)
function val = TSDGroup_18(x) %function calling
%UNKNOWN VALUES a function for the equations in problem 6.16 solving for following values in problem schematic %input parameter: x — vector ?%1 te evaporating temperature %2 tc condensing temperature %3 P power %4 taout temperature exiting a %5 tbout temperature exiting b %6 qe evaporator %7 qc condensor
%Define Knowns %Evaporator, converted from W/k to kW/K in order to keep units cohesive
UA1= 31.0; %kW/K

w1= 6.5; %kg/s

%Condensor, converted from W/k to kW/k in order to keep units cohesive
UA2= 25.0; %kW/K
w2= 7.5; %kg/s
%Specific Weight
cp= 4.2; %kJ/kgK
%provided values for input temperature in degrees K %

tain=[283.15 285.65 288.15]
tain=10; %??

%provided values for input temperature in degrees K %
tbin=[298.15 303.15]
tbin= 30; %??
%EQUATIONS %1: Equation 1 %2: Equation 2 %3: Equation 3 %4: Equation 4 %5: Equation 5 %6: Equation 6 %7: Equation 7
te=x(1);
tc=x(2);
P=x(3);
taout=x(4); tbout=x(5);
qe=x(6);
qc=x(7);
%Calculations and Gathered Equations
wb =2; %fake value


%Equation 1 (q condensor)
val(1)= wb*cp*(tain-taout)-qc;
%Equation 2 (q evaporator)
val(2)= wb*cp*(tbout-tbin)-qe;
%Equation 3 (balancing the problem schematic)
val(3)=qe+P-qc;
%Equation 4 (curve fitting for P)
val(4)=(-2.89415e-5*(tc^2) + 1.63078e-3*(tc) - 3.80394e-2)*(te^2)+(1.44295e-3*(tc^2) - 2.47310e-2*tc - 1.88758e-1)*(te)+(-8.99105e-3*(tc^2) + 1.94087e0*(tc)- 3.51076e1)-P;
%Equation 5 (curve fitting for qe)
val(5)=(-1.96620e-4*(tc^2) + 2.08655e-2*(tc) - 3.56666e-1)*(te^2)+(3.51630e-3*(tc^2) - 4.42262e-1*(tc)+ 1.90407e1)*te+(-7.10395e-3*(tc^2)-4.84674e0*tc + 2.38256e2)-qe;
%Equation 6
UAc = 3; %fake value
val(6)=(tbin+(tc-tbin)*(1-exp(-UAc/wb*cp)))-tbout;
%Equation 7
UAe=5; %fake value
wa=7; %fake
val(7)=(tain+(te-tain)*(1-exp(-UAe/wa*cp)))-taout;
fsolve(@(x)val,0)
end