What is wrong with this code?

2 vues (au cours des 30 derniers jours)
Jihaad Barnett
Jihaad Barnett le 26 Fév 2021
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

Réponses (1)

Megumi Fukuda
Megumi Fukuda le 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.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by