I am currently working on coding polymerization of PLA in a batch reactor keep getting error message. My professor helped my group get to this point but eveytime we run it we get,
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
We have tried everything we can think of to fix this problem but we arent sure why this is happening or how to fix it.
Error in sad_girl_Project (line 46)
u0=[P0 zeros(N,1) 0] ;
function sad_girl_Project
T = 180+273.15;
Keq=10;
lk1=-(6810.3/T)+6.1928
k1=exp(lk1)
km1=k1/Keq
P0=10;
N=100;
function dudt=deq(t,u)
P= u(1:N);
W= u(N-1);
sum3= sum(P);
sum4=0;
for ii=1:N
sum1 = 0;
for jj=1:ii-1
sum1= sum1 + P(ii-jj)*P(jj);
end
sum2= sum(P(ii+1:N));
dudt(ii)= k1*sum1 + 2*km1*W*sum2 - ...
2*k1*P(ii)*sum3 - km1*W*(ii-1)*P(ii);
sum4 = sum4 + (ii-1)*P(ii);
end
dudt(N+1)= k1*sum3^2 - km1*W*sum4;
dwdt(N+1)=0;
dudt=[dudt; dwdt];
end
m=[0 24*3600] ;
u0=[P0 zeros(N,1) 0] ;
[t,u]=ode15(@deq,m,u0) ;
figure(1)
plot(t,u)
title('Time Vs. Molecular Weight')
xlabel('Time []')
ylabel('Concentration []')
end
2 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/493416-keep-getting-error-message-on-my-ode-function#comment_771965
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/493416-keep-getting-error-message-on-my-ode-function#comment_771965
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/493416-keep-getting-error-message-on-my-ode-function#comment_772320
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/493416-keep-getting-error-message-on-my-ode-function#comment_772320
Sign in to comment.