Matrix dimension must agree
조회 수: 1 (최근 30일)
이전 댓글 표시
%% am running a long script with already made fuction and I want to run them
%from a given point to a certain range with alotted plot size and get their
%values. my fuction files and the inputs are given below.I want to run the
%script with a pressure ranging from 408.3 to 3000000 with a stepsize of
%5000.
%% the first function file
function[Ko]=Wilson_correlation(Pc, Tc,P,Omega,T)
%this function calculates wilson calculation as the initial guess for K i.e
%the equilibrum ratio.
Ko=(Pc./P).*exp(5.37.*(1+Omega).*(1-Tc/T));
end
%% the second function file
function [x,y,alphaV,fl,Fv] = PTFLASH_VLE_PRVDW(Pc, Tc, Omega, kappa, eta, P, T, z, Ko)
%The funtion PTFLASH_VLE_PRVDW makes a PT-FLASH calculation for a mixture
%at given P, T and overall composition (z) using PR-CEoS and VDW MIXING RULES.
%This function requires MIXRULES_VDW and FUGACITY_INMIX_PRVDW funtions to run.
%All input/output data are expressed in SI.
%P[Pa], T[K], w[dimensionless], V[m^3/mol], Z[dimensionless]
%giving a firt value for c
c=length(z);
%firt verification for alphaV between 0 and 1
psi_0=sum(z.*(Ko-1));
psi_1=sum(z.*(Ko-1)./Ko);
if psi_0*psi_1>=0
x=0;
y=0;
alphaV=0;
fl=0;
Fv=0;
else
iter=0;
fl=zeros(1,c);
Fv=ones(1,c);
K=Ko;
while max(abs((Fv-fl)./Fv))>0.00001 && iter<1000 && psi_0*psi_1<0
[ alphaV ] = RACHFORDRICE_BISECT( K,z );
x=z./((1-alphaV)+alphaV*K);
y=K.*x;
[fil,~,fl,~] = fugacity_INMIX_PRVDW( Pc,Tc,Omega,kappa,eta,P,T,x );
[~,fiv,~,Fv] = fugacity_INMIX_PRVDW( Pc,Tc,Omega,kappa,eta,P,T,x );
K=fil./fiv;
psi_0=sum(z.*(K-1));
psi_1=sum(z.*(K-1)./K);
iter=iter+1;
end
end
end
%% input
TMIN=320;
Tc=[190.6 305.3 369.8 425.1 469.7 507.6 568.7 658.1 722];
dT=0.01;
Omega=[0.011 0.098 0.149 0.200 0.252 0.301 0.346 0.577 0.721];
Pc=[4.599E06 4.872E06 4.248E06 3.796E06 3.37E06 3.025E06 2.49E06 1.817E06 1.401E06];
P=4.083e2:50000:3000000
z=[0.70 0.08 0.07 0.03 0.01 0.02 0.04 0.02 0.03];
kappa=zeros(9);
eta=zeros(9);
T=320;
[Ko]=Wilson_correlation(Pc, Tc,P,Omega,T);
[x,y,alphaV1,fl,Fv] = PTFLASH_VLE_PRVDW(Pc, Tc, Omega, kappa, eta, P, T, z, Ko);
K=y./x
%%
%please help me fix this so am able to make plot between alphav values vs P &K vs P
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 5월 14일
Pc is 1 x 9 given as explicit values
P is 1 x 60 given as colon list.
Pc./P is attempting to divide 1 x 9, by 1 x 60.
The other values involved in the function are all 1 x 9 or 1 x 1.
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!