What is wrong with this matlab program?

1 次查看(过去 30 天)
I have a homework question about a small-world network. My neuron model is FitzHugh Naguma (electrical coupling). I got this error ??? Error using ==> times Matrix dimensions must agree.
Error in ==> elec_syn_vr_swn at 42 I_syn = ( gsyn.* ( sum((Cshort).*con_mat,2).*x' - con_mat*x' ) )'; and small-world networks matlab codes are true or not? My program is:
%FHN Modeli_VR_Q_e_small-world_networks
clc;clf;clear;
deltat=0.01;
t=250;
j=0;
N=3;
con_mat=ones(N,N)-eye(N); %all-to-all network
for B=0.0:0.001:0.04
B
a=1.01;
j=j+1;
e=0.01;
A=0.01;
ohm=5;
w=0.1;
x=-0.8*ones(1,3);
y=-0.2*ones(1,3);
Isyn=zeros(1,3);
gsyn=0.1;
Qsin=0;
Qcos=0;
%SMALL_WORLD NETWORKS
n=50;%number of nodes
k=4;%the nearest neighbor
p=0.5;%coupling probability
r=zeros(1,n);r(2:k+1)=1;r(n-k+1:n)=1;
C=toeplitz(r)
%subplot(2,2,1), spy(C)
%subplot(2,2,2)
v=find(rand(n,1)< p);
Cshort=sparse(v,ceil(n*rand(size(v))),ones(size(v)),n,n)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
for i=1:t/deltat
x=x+deltat.*(x - x.^3/3 -y -Isyn)./e;
y=y+deltat.*(x +a +A.*cos(w*i*deltat) +B*cos(ohm*i*deltat) );
I_syn = ( gsyn.* ( sum((Cshort)'.*con_mat,2).*x' - con_mat*x' ) )';
Qv=x;
Qv(find(Qv<0))=-1;
Qvav=(1/N)*sum(Qv);
Qsin=Qsin+2*Qvav(2)*sin(w*i*deltat);
Qcos=Qcos+2*Qvav(2)*cos(w*i*deltat);
end
Qsin=Qsin/(t/deltat);
Qcos=Qcos/(t/deltat);
Qson(j)=sqrt(Qsin^2+Qcos^2);
end
Bplot=0.0:0.001:0.04;
plot(Bplot,Qson,'-o'),
grid on;
xlabel('B');
ylabel('Q');
  1 个评论
Walter Roberson
Walter Roberson 2013-12-17
What difference do you observe between what you expect and what you get? Are you receiving an error message?

请先登录,再进行评论。

采纳的回答

Paul
Paul 2013-12-18
The Line
sum((Cshort)'.*con_mat,2)
is what is causing your error.
Matlab uses matrix multiplication these matrices are not able to be multiplied together and so will cause an error.
Check your working to see if you have created these matrices correctly. What are they superposed to be ?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by