马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
MATLAB运行程序时出现??? Index exceeds matrix dimensions错误,下面是程序,麻烦大家帮我看看好吗,多谢大家了!
%以不同文化资源增长变化率下文化创意产业集群规模演化模拟为例
clear all; n=20; cmax=1500; time=100; s=zeros(n,n);
s((n-2)/2:(n-2)/2+1,(n-2)/2:(n-2)/2+1)=ones(2,2);
R0=0.8; s0=s; r=rand(n); t=1; stsum1(t)=0;
for i=1:n, for j=1:n
st{t}=s0; a=0.2; socv=0.4; labv=6; serv=0.4; polv=6; marv=0.4;
e1{t}=1./(1+100*exp(-a.*(stsum1(t))));
e2{t}=1./(1+100*exp(-socv.*t));
e3{t}=1./(1+100*exp(-labv.*4*(t/time)*(1-t/time)));
e4{t}=1./(1+100*exp(-serv.*t));
e5{t}=1./(1+100*exp(-polv.*4.*(t/time)*(1-t/time)));
e6{t}=1./(1+100*exp(-marv.*t));
e{t}= e1{t}.* e2{t}.* e3{t}.*e4{t}.* e5{t}.* e6{t};
p=0.2; f{t}=1./(1+100*exp(-p.*(stsum1(t))));
R{t}(i,j)=(1-stsum1(t)/cmax)* (1+e{t})*(1+f{t}(i,j));
if st{t}(i,j)>0, stsum1(t)=stsum1(t)+st{t}(i,j); end
end; end
t=2; stsum1(t)=0; a=0.2; socv=0.4;
labv=6; serv=0.4; polv=6; marv=0.4;
e1{t}=1-1./(1+100*exp(-a.*(stsum1(t-1))));
e2{t}=1./(1+100*exp(-socv.*t));
e3{t}=1./(1+100*exp(-labv.*4.*(t/time)*(1-t/time)));
e4{t}=1./(1+100*exp(-serv.*t));
e5{t}=1./(1+100*exp(-polv.*4.*(t/time)*(1-t/time)));
e6{t}=1./(1+100*exp(-marv.*t));
e{t}= e1{t}.* e2{t}.* e3{t}.*e4{t}.* e5{t}.* e6{t};
p=0.2; f{t}=1./(1+100*exp(-p.*(stsum1(t-1)))); pnt{t-1}=pernei(st{t-1},n);
for i=1:n, for j=1:n
if stsum1(t-1)==cmax, R{t}(i,j)=0.1.*(1+e{t})*(1+f{t}(i,j));
else R{t}(i,j)=(1-stsum1(t)/cmax)* (1+e{t})*(1+f{t}(i,j));
end
end; end
for i=1:n, for j=1:n
if R{t}(i,j)>=R0&R{t}(i,j)>=r{t-1}(i,j)&pnt{t-1}(i,j)>=0&r(i,j)>=0.3
st{t}(i,j)=st{t-1}(i,j)+1;
elseif R{t}(i,j)>=R0&R{t}(i,j)>=r{t-1}(i,j)&pnt{t-1}(i,j)<0
st{t}(i,j)= st{t-1}(i,j);
elseif R{t}(i,j)>=R0&R{t}(i,j)<r{t-1}(i,j)&r(i,j)>=0.3
st{t}(i,j)= st{t-1}(i,j);
elseif R{t}(i,j)<R0, st{t}(i,j)= st{t-1}(i,j)-1;
end
if st{t}(i,j)<0, st{t}(i,j)=0; end
stsum1(t)=stsum1(t)+st{t}(i,j);
end; end
for t=3:time
stsum1(t)=0; a=0.2; socv=0.4; labv=6; serv=0.4; polv=6; marv=0.4;
e1{t}=1./(1+100*exp(-a.*(stsum1(t-1))));
e2{t}=1./(1+100*exp(-socv.*t));
e3{t}=1./(1+100*exp(-labv.*4*(t/time)*(1-t/time)));
e4{t}=1./(1+100*exp(-serv.*t));
e5{t}=1./(1+100*exp(-polv.*4.*(t/time)*(1-t/time)));
e6{t}=1./(1+100*exp(-marv.*t));
e{t}= e1{t}.* e2{t}.* e3{t}.*e4{t}.* e5{t}.* e6{t};
p=0.2; f{t}=1./(1+100*exp(-p.*(stsum1(t-1))));
pnt{t-1}=pernei(st{t-1},n);
for i=1:n, for j=1:n
if stsum1(t-1)==cmax, R{t}(i,j)=0.1*(1+e{t})*(1+f{t}(i,j));
else R{t}(i,j)=(1-stsum1(t)/cmax)* (1+e{t})*(1+f{t}(i,j));
end
end; end
for i=1:n, for j=1:n
if R{t}(i,j)>=R0&R{t}(i,j)>=r{t-1}(i,j)&pnt{t-1}(i,j)-pnt{t-2}(i,j)>=0&r(i,j)>=0.3
st{t}(i,j)= st{t-1}(i,j)+1;
elseif R{t}(i,j)>=R0&R{t}(i,j)>=r{t-1}(i,j)&pnt{t-1}(i,j)-pnt{t-2}(i,j)<0
st{t}(i,j)= st{t-1}(i,j);
elseif R{t}(i,j)>=R0&R{t}(i,j)<r{t-1}(i,j) &r(i,j)>=0.3
st{t}(i,j)= st{t-1}(i,j);
elseif R{t}(i,j)<R0, st{t}(i,j)= st{t-1}(i,j)-1;
end
if st{t}(i,j)<0, st{t}(i,j)=0; end
stsum1(t)=stsum1(t)+st{t}(i,j);
end; end
st{t}; pnt{t+1}=pernei(st{t},n); pnt{t+1};
end
t=1:time;
plot(t,stsum1)
title('文化创意产业集群规模演化')
xlabel('模拟次数');ylabel('集群资产总量')
legend('a=0.2')
[ 本帖最后由 ChaChing 于 2009-12-26 23:22 编辑 ] |