What is wrong with this code?

2 次查看(过去 30 天)
Jihaad Barnett
Jihaad Barnett 2021-2-26
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

回答(1 个)

Megumi Fukuda
Megumi Fukuda 2021-3-1
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.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by