Index exceeds the number of array elements (1).

조회 수: 1 (최근 30일)
Sergio Fonnegra Gomez
Sergio Fonnegra Gomez 2021년 9월 9일
댓글: Sulaymon Eshkabilov 2021년 9월 9일
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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)

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 9일
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
Sergio Fonnegra Gomez
Sergio Fonnegra Gomez 2021년 9월 9일
Thank you very much, your answer is true, I appreciate it
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 9일
Most welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by