Matrix dimensions must agree.

I have an error in the following code. Could anyone help me to correct it?
clear, clc;
aeta=0;
beta=0.75;
d=0;
eps=0.0006;
sigma=1/3;
Gam=1./8;
h=0.1;
alpha=[0.5; 0.6; 0.7; 1.0];
M=2/(2-alpha);
t=0:h:100;
n=length(t);
m=length(alpha);
solS=[]; solE=[]; solI=[]; solN=[];
for k=1:m
S=zeros(n, 1);
E=S; I=S; N=S;
E(1)=20000; I(1)=1; N(1)=10*10^6;
S(1)=N(1)-E(1)-1;
for i = 2 : n-1
S(i+1)=S(1)+((1-alpha)/M+(3*h)/(2*M))*(aeta-(beta*S(i)*I(i))/N(i)-d*S(i))-((1-alpha)/M+(alpha*h)/(2*M))*(aeta-(beta*S(i-1)*I(i-1))/N(i-1)-d*S(i-1));
E(i+1)=E(i)+(h^alpha(k)/gamma(alpha(k)+1))*((beta*S(i)*I(i))/N(i)-(sigma+d)*E(i));
I(i+1)=I(i)+(h^alpha(k)/gamma(alpha(k)+1))*(sigma*E(i)-(Gam+d+eps)*I(i));
N(i+1)=N(i)+(h^alpha(k)/gamma(alpha(k)+1))*(aeta-d*N(i)+eps*I(i));
end
solS(:, k) = S(:); solE(:, k) = E(:); solI(:, k) = I(:); solN(:, k) = N(:);
end
plot (t,solI(:,1),'r', t, solI(:,2),'g', t, solI(:,3),'k', t, solI(:,4),'b');
xlabel ('Time'), ylabel('Infectious'), title('Size of the infectious versus time with no treatment for diferent values of order alpha');
legend ('alpha=0.5','alpha=0.6','alpha=0.7','alpha=1.0')

2 个评论

YOur alpha is array...you cnnot do like that....replacing / with ./ also will not work. May be you have to run a loop for alpha and do other caculations in vector.
Thank you dear... I will see

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by