フィルターのクリア

Index in position 1 exceeds array bounds

1 回表示 (過去 30 日間)
Chinaemerem Valentine Nwobi
Chinaemerem Valentine Nwobi 2019 年 5 月 21 日
I am trying to run a script with a sub function file and enclosed are the function files and the input data but it keeps saying"Index in position 1 exceeds array bounds. please look at my scripts to know what am doing wrong.
%%
first function
function [gamma,a]=ACTIVITY_WILSON(MW,rhoL,BIP,T,Z)
R=8.314;
c=length(Z);
% Molar volumes of the pure liquid components composing the mixture
Vl=1./((rhoL*1000)./MW);
% Lambda terms (dimensionless) of the Wilson formula
for i=1:c
for j=1:c
Lambda(i,j)=(Vl(j)/Vl(i))*exp(-BIP(i,j)/(R*T));
end
end
for i=1:c
for j=1:c
A=sum(Z.*Lambda(j,:));
C(j)=Z(j)*Lambda(j,i)/A;
end
lngamma(i)=1-log(sum(Z.*Lambda(i,:)))-sum(C);
gamma(i)=exp(lngamma(i));
a(i)=gamma(i)*Z(i);
end
end
%% main function file to be called
%
function[PB,Ybub]=PB_VLE_Wilson(Z,C,MW,rhoL,T,BIP)
% this is a function that calculates the bubble point using the wilson
% activity coeefficient model.
c=length(Z);
for i=1:c
Psi=exp((C(i,1))+(C(i,2)/T)+(C(i,3)*log(T))+(C(i,4)*T^C(i,5)));
[gamma,~]=ACTIVITY_WILSON(MW,rhoL,BIP,T,Z);
PB=sum(Psi.*Z*gamma);
Ybub=Psi.*gamma/PB;
end
%% Input parameters
Z=[0.1 0.9];
C1=[88.134 153.23];
C2=[-8498.6 -10055];
C3=[-9.0766 -19.488];
C4=[8.330e18 1.6426e5];
C5=[6 2];
C = [C1' C2' C3' C4' C5'];
BIP=[196.2500 386.1330];
MW=[60.09 100.16];
rhoL=[803 802];
T=353.15;
P=0.4e5;
[PB,Ybub]=PB_VLE_Wilson(Z,C,MW,rhoL,T,BIP)
  3 件のコメント
Adam
Adam 2019 年 5 月 21 日
Use the debugger - the simplest way to find out what is wrong in so many cases. In particular the option to Stop/pause on errors. It puts you right at the error allowing you to investigate on command line by looking at the sizes and contents, types, etc of the relevant variables. It usually takes less time than it does to navigate to Matlab Answers and post a question, let alonoe wait for an answer!
Chinaemerem Valentine Nwobi
Chinaemerem Valentine Nwobi 2019 年 5 月 22 日
thank you!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by