Index exceeds the number of array elements (1).

1 visualización (últimos 30 días)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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)

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 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 comentarios
Sergio Fonnegra Gomez
Sergio Fonnegra Gomez el 9 de Sept. de 2021
Thank you very much, your answer is true, I appreciate it
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 2021
Most welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by