Why am i getting "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function ydot=problem4data(W,X)
fa0=5; %mol/s
fb0=2*fa0;%mol/s
fi=2*fa0; %mol/s
ca0=2; %mol/dm^3
T1=325; %K
Ta=300; %K
T2=305;%K
Cpa= 20;%cal/molK
Cpb=Cpa;
Cpc=Cpa;
E=25; %kcal/mol
R=1.987*.001;%kcal/molK
Cpi=18; %cal/molK
Ua=320; %cal/s.m^3.K
Hrx= -20; %Kcal/mol
k2=.0002; %dm^6/kg.mol.s
alpha=.000115; %kg^-1
Cpsum=Cpa+Cpb+Cpi;
x=[0:0.1:1];%assumption
T=T1+((x.*(-Hrx))./(Cpsum));
Kc2=1000;
Kc1=Kc2.*exp((Hrx./R).*((1./T2)-(1./T)));
k1=k2.*exp((E./R).*((1./Ta)-(1./T)));
y1=1;%assumption
xenum=((3.*Kc1)./4)- sqrt(((3.*Kc1)./4)-((2.*Kc1).*((Kc1./4)-1)));%numerator xe equation
xedenom=2.*((Kc1./4)-1);%denominator xe equation
xe=xenum./xedenom;
pb= 1400; %kg/m^3
ra=-((k1.*ca0.*(T./T1).*y1).^2).*((1-x).*(2-x)-((4*x.^2)./Kc1));
rae=-((k1.*ca0.*(T./T1).*y1).^2).*((1-xe).*(2-xe)-((4*xe.^2)/Kc1));
Tnum=(Ua./pb).*(Ta-T)+(ra.*Hrx);
Tdenom=(fa0+fb0+fi).*(Cpsum);
ydot(1)=(-ra)./fa0;
ydot(2)=-rae./fa0;
ydot(3)=Tnum./Tdenom;
ydot(4)=(-alpha./(2.*y1)).*(T./T1);
ydot=ydot';
end
6 Kommentare
Akzeptierte Antwort
Raj
am 10 Mai 2019
You must be getting error at line number 34 in your code. That's because your 'ra' is a 1x11 double type matrix which (after dividing by fa0) you are tying to assign to a single element of ydot. Again in the next line you are trying to assign 'rae' which is a 1x11 complex double type matrix to single element of ydot.
Try changing your code like this:
ydot(1,:)=(-ra)./fa0;
ydot(2,:)=-rae./fa0;
ydot(3,:)=Tnum./Tdenom;
ydot(4,:)=(-alpha./(2.*y1)).*(T./T1);
This will give you a ydot matrix of 11x4 complex double type matrix (after the transpose) in which your third and fourth columns will have repeated real values. you can extract the values out of ydot as per your requirement in the script where you are calling this function.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!