What is wrong with this code?
2 views (last 30 days)
Show older comments
I am getting an error message "Array indices must be positive integers or logical values.
Error in take_home_exam_problem2 (line 23)
delT2=delT1*exp(-UA((1/Ch)+(1/Cc)))"
I'm not even sure what an array indices is in this problem, can anyone help me with this?
My code:
start
%user section
%assign our variables
Th1=575;% K inlet hot stream temperature
Tc1=320;% K inlet cold stream temperature
UA=25000;% kJ/(K-hr) heat transfer coefficient
Cph=2.0;% J/(kg-K) heat capacity of hot stream
Cpc=1.1;% J/(kg-K) heat capacity of cold stream
mh=2500;% kg/hr hot stream
mc=800;% kg/hr cold stream
%Main program
%do matlab calculations
delT1=Th1-Tc1
Ch=mh*Cph
Cc=mc*Cpc
delT2=delT1*exp(-UA((1/Ch)+(1/Cc)))
q=UA*((delT2-delT1)/log(delT2/delT1))
end
0 Comments
Answers (1)
Megumi Fukuda
on 1 Mar 2021
I assume this is what you meant?
delT2=delT1*exp(-UA*((1/Ch)+(1/Cc)))
See the * between -UA and (.
-UA((1/Ch)+(1/Cc)) means (1/Ch)+(1/Cc)th element of -UA.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!