# Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parenthe

2 views (last 30 days)
UDIT on 19 Aug 2023
Edited: Torsten on 19 Aug 2023
m=5000;%input('Enter the mass of water in kg -');
cpw=4.187;%Cp of water is taken as 4.187 KJ/kg K
T1=300;%input('Enter the inital temperature of water in kelvin :- '); %water initial temperature
Tinter1=250;%input('Enter the intermediate temperature of water in kelvin :- '); %first reservoir temperature
T2=150;%input('Enter the final temperature of water in kelvin :- ');
for m=1:5:30
Q1=m*cpw*(Tinter1-T1)
Q2=m*cpw*(T2-Tinter1);
deltaSwater= m*cpw*[log(Tinter1/T1)+log(T2/Tinter1)];
deltaSreservoir1=-Q1/(Tinter1);
deltaSreservoir2=-Q2/(T2);
deltaSUniverse=deltaSwater+deltaSreservoir1+deltaSreservoir2;
disp('Analysis for TER and system')
fprintf('Heat transferred from TER1 to water is:- %f kJ \n',Q1)
fprintf('Heat transferred from TER2 to water is:- %f kJ \n',Q2)
fprintf('deltaSwater=%f kJ/K \n',deltaSwater)
fprintf('deltaSreservoir1= %f kJ/K\n',deltaSreservoir1)
fprintf('deltaSreservoir2= %f kJ/K\n',deltaSreservoir2)
fprintf('deltaSUniverse= %f kJ/K\n',deltaSUniverse)
plot(m,Q1,'-b')
hold on
plot(m,Q2,'og')
hold on
plot(m,deltaSwater,'* r')
hold on
plot(m,deltaSreservoir1,'+c')
hold on
plot(m,deltaSreservoir2,':m')
hold on
plot(m,deltaSUniverse,'xk')
end
Q1 = -209.3500
Analysis for TER and system
Heat transferred from TER1 to water is:- -209.350000 kJ
Heat transferred from TER2 to water is:- -418.700000 kJ
deltaSwater=-2.902207 kJ/K
deltaSreservoir1= 0.837400 kJ/K
deltaSreservoir2= 2.791333 kJ/K
deltaSUniverse= 0.726526 kJ/K
Q1 = -1.2561e+03
Analysis for TER and system
Heat transferred from TER1 to water is:- -1256.100000 kJ
Heat transferred from TER2 to water is:- -2512.200000 kJ
deltaSwater=-17.413243 kJ/K
deltaSreservoir1= 5.024400 kJ/K
deltaSreservoir2= 16.748000 kJ/K
deltaSUniverse= 4.359157 kJ/K
Q1 = -2.3028e+03
Analysis for TER and system
Heat transferred from TER1 to water is:- -2302.850000 kJ
Heat transferred from TER2 to water is:- -4605.700000 kJ
deltaSwater=-31.924280 kJ/K
deltaSreservoir1= 9.211400 kJ/K
deltaSreservoir2= 30.704667 kJ/K
deltaSUniverse= 7.991787 kJ/K
Q1 = -3.3496e+03
Analysis for TER and system
Heat transferred from TER1 to water is:- -3349.600000 kJ
Heat transferred from TER2 to water is:- -6699.200000 kJ
deltaSwater=-46.435316 kJ/K
deltaSreservoir1= 13.398400 kJ/K
deltaSreservoir2= 44.661333 kJ/K
deltaSUniverse= 11.624417 kJ/K
Q1 = -4.3964e+03
Analysis for TER and system
Heat transferred from TER1 to water is:- -4396.350000 kJ
Heat transferred from TER2 to water is:- -8792.700000 kJ
deltaSwater=-60.946352 kJ/K
deltaSreservoir1= 17.585400 kJ/K
deltaSreservoir2= 58.618000 kJ/K
deltaSUniverse= 15.257048 kJ/K
Q1 = -5.4431e+03
Analysis for TER and system
Heat transferred from TER1 to water is:- -5443.100000 kJ
Heat transferred from TER2 to water is:- -10886.200000 kJ
deltaSwater=-75.457388 kJ/K
deltaSreservoir1= 21.772400 kJ/K
deltaSreservoir2= 72.574667 kJ/K
deltaSUniverse= 18.889678 kJ/K

Torsten on 19 Aug 2023
Edited: Torsten on 19 Aug 2023
Works for me (see above).