Index exceeds the number of array elements (1).
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sergio Fonnegra Gomez
am 9 Sep. 2021
Kommentiert: Sulaymon Eshkabilov
am 9 Sep. 2021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CALCULO DE LÍNEAS ADIABATICAS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
T=300;
%Constantes del agua para Cp
AA=276370;
BA=-2090.1;
CA=8.125;
DA=-0.014116;
EA=9.3701E-06;
%%%%%%%%%%%%%%%%%%%%%
%Constantes del aire para Cp
AI=28.11;
BI=0.1967E-02;
CI=0.4802E-05;
DI=-1.966E-09;
EI=0.0;
%%%%%%%%%%%%%%%%%%%%%
% Constates para el landa del agua
AL=-0.432;
BL=0.0057255;
CL=-8.078E-06;
DL=1.861E-09;
EL=0.0;
Cpagua=AA+BA*T+CA*T^2+DA*T^3+EA*T^4;
Cpaire=AI+BI*T+CI*T^2+DI*T^3+EI*T^4;
Y=Y(1,:);
for i=1:length(Y)
tol=0.001;
TBH=T(i);
for j=1:100
landa=AL+BL*T+CL*T^2+DL*T^3+EL*T^4;
term1=(Cpaire*(T(i)-TBH)+Y(i));
term2=(landa+Cpagua*(T(i)-TBH));
Ysat=(term1+term2)/landa;
Psat=((Ysat.*(Magua/Maire))./(1+Ysat.*(Magua/Maire)))*P1;
Tbhn=(B/(A-log10(Psat)))-C;
Error=abs(Tbhn-TBH);
Ysat=real(Ysat);
if Error<=tol
break
else
TBH=Tbhn;
end
end
end
Hello everyone, I have a problem in TBH = T (i) and I really don't know how to solve it, (I'm new to programming)
0 Kommentare
Akzeptierte Antwort
Sulaymon Eshkabilov
am 9 Sep. 2021
Note the size issues of the following variables pre-defined in your code:
T=300; % Size 1 - by - 1. And you are trying to recall it within a loop:
...
... % Maybe you have overlooked to define T variable's value range before the loop
Y = Y(1,:)% % Y is not defined or given in your code unless you are calling it from the workspace or pre-loading it from another file.
for i = 1:length(Y)
TBH=T(i); % T =300
...
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!