Array Indices must be positive integers or logical values - problem
Afficher commentaires plus anciens
Hello guys, so I am trying to run this code that I have attached but in the final portion (lines 56-59) I am getting the error "array indices must be positive integers or logical values." What is happening here?
clc
clear all
%% Problem 1
thermoCouple = 1:1:7;
zeroHz = [73.35 72.59 71.58 70.05 68.11 64.04 60.86];
fiveHz = [60.78 58.58 55.64 51.33 45.81 35.24 28.29];
fifteenHz = [57.50 55.20 52.18 47.75 42.70 32.78 27.36];
twentyfiveHz = [54.28 51.85 48.75 44.28 39.80 29.89 25.32];
freeStreamT0 = 24;
freeStreamT5 = 24.2;
freeStreamT15 = 23.2;
freeStreamT25 = 24.3;
i = 1;
for i = 1:7
calcTemp0(i) = (zeroHz(i)-freeStreamT0)/(80-freeStreamT0);
calcTemp5(i) = (fiveHz(i)-freeStreamT5)/(80-freeStreamT5);
calcTemp15(i) = (fifteenHz(i)-freeStreamT15)/(80-freeStreamT15);
calcTemp25(i) = (twentyfiveHz(i)-freeStreamT25)/(80-freeStreamT25);
end
% Constant Area Fin Boundary Conditions
length = 0.292;
thermoCoupleLengths = [0.009 0.02 0.03 0.05 0.08 0.15 0.29];
k = 167;
diameterFin = 0.025;
pf = diameterFin * pi;
ac = (pi * (diameterFin^2))/4;
PFree = [0.1 1 9.9 29.5];
for i = 1:4
PFreePa(i) = PFree(i)*9.80665;
end
for i = 1:4
VFree(i) = sqrt((PFreePa(i)^2)/1.225);
end
for i = 1:4
Re(i) = (VFree(i)*0.25)/(1.81*10^-5);
end
Pr = 0.71;
for i = 1:4
Nu(i) = 0.3 + (0.62*(Re(i)^(1/2))*(Pr^(1/3)))/((1+(0.4/Pr)^(2/3))^(1/4))*((1+(Re(i)/282000)^(5/8))^(4/5));
end
for i = 1:4
h(i) = (Nu(i)*k)/diameterFin;
end
for i = 1:4
m(i) = sqrt((h(i)*pf)/(k*ac));
end
mu = m(4);
he = h(4);
for i = 1:7
convectionCase(i) = (cosh(mu*(length-thermoCoupleLengths(i)))+(he/(mu*k))*sinh(mu(length-thermoCoupleLengths(i))))/(cosh(mu*length)+(he/(mu*k))*sinh(mu*length));
adiabaticCase(i) = (cosh(mu*(length-thermoCoupleLengths(i))))/cosh(mu*length);
prescribedCase(i) = (((twentyfiveHz(i)-freeStreamT0)/80-freeStreamT0)*sinh(mu*thermoCoupleLengths(i))+sinh(mu*(length-thermoCoupleLengths(i))))/sinh(mu*length);
infiniteCase(i) = e^-(mu*thermoCoupleLengths(i));
end
Réponses (1)
Image Analyst
le 17 Avr 2023
See the FAQ for a thorough discussion
Don't use length as your variable name. That is the name of a built-in function.
mu is a scalar not an array so you can't do
convectionCase(i) = (cosh(mu*(length-thermoCoupleLengths(i)))+(he/(mu*k))*sinh(mu(length-thermoCoupleLengths(i))))/(cosh(mu*length)+(he/(mu*k))*sinh(mu*length));
perhaps you meant
convectionCase(i) = (cosh(mu*(length-thermoCoupleLengths(i)))+(he/(mu*k))*sinh(mu*(length-thermoCoupleLengths(i))))/(cosh(mu*length)+(he/(mu*k))*sinh(mu*length));
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!