What is wrong with this code?

조회 수: 2 (최근 30일)
Jihaad Barnett
Jihaad Barnett 2021년 2월 26일
답변: Megumi Fukuda 2021년 3월 1일
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