Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm struggling with this problem, and don't know how to fix it, please help :)
I'm programing the PRSV ecuation of state for a multicomponent system.
I tried with the command [z]= prsv(800,1000*1000,[647.1 512.6],[22055*1000 8097*1000],[0.345 0.564],[-0.06635 -0.16816],[0.5 0.5],0) and that error shows up, i know it has something to do with the matrix size but dont know what specifically.
function[z]= prsv(T,P,Tc,Pc,w,k1,x,kij)
nrosust=length(Tc);
R=8.314772;
for i=1:nrosust
k0(i)=0.378893+1.4897153*w-0.17131848*w.^2+0.0196554*w.^3;
k(i)=k0(i)+k1*(1+(T/Tc(i))^0.5)*(0.7-(T/Tc(i)));
alpha(i)=(1+k(i)*(1-((T/Tc(i))^0.5)))^2;
a(i)=(0.457235*(R^2*Tc(i).^2/Pc(i)))*alpha(i);
b(i)=0.07779607*(R*Tc(i)/Pc(i));
end
sum_a=0;
for i=1:nrosust
for j=1:nrosust
aij(i,j)=(a(i)*a(j))^0.5*(1-kij(i,j));
sum_a=sum_a+x(i)*x(j)*aij(i,j);
end
end
b=sum(x.*b);
A=sum_a*P/(R*T)^2;
B=b*P/(R*T);
Pol=[1 -1+B A-3*B^2-2*B -A*B+B^2+B^3];
Z=roots(Pol);
z=max(Z);
댓글 수: 0
채택된 답변
the cyclist
2021년 5월 18일
In this line:
k0(i)=0.378893+1.4897153*w-0.17131848*w.^2+0.0196554*w.^3;
w is a 2-element vector, and you are trying to assign it to a single element of k0.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!