how to solve a Conditional ODE problem
Afficher commentaires plus anciens
I am trying to solve a problem involving a neural network type model as shown in the picture.

However g is a conditional function and I am not sure how to incorporate this into an ode solver.

Any help would be appreciated!
my unsuccessful attempt:
clear all
close all
N=50; %number of units (i)
w=zeros(N,N); %synaptic efficiency matrix
a=0.7; %reducing factor alpha
y=[];
t=linspace(0,9,100); %time vector
for i=1:N
K=randi([0 N-1],1,1); %selects K (j) out of N-1 units acting on unit i
w(i,:)=[zeros(1,N-K),ones(1,K)]*-1; %sets corresponding i,j of connection matrix to -1 indicating connection, otherwise set to 0 (no connection)
w(i,:)=w(:,1)(randperm(N)); %randomly orders connections
end
for i=1:N
for j=1:N
if w(i,j)==-1;
w(j,i)=0;
end %if already a connection between j action on i cannot be connect for i acting on j
end
end
R = normrnd(0,.001,1,N); %mean of 0 std .001
tau=-(K-1.5)*[R]; %generation of threshold vector
tau=tau' %convert to column vector
d=randi([0 N-1],1,1) ;
for k=1:d
w(:,k)=w(:,k)*a;
end %synapse connection defficiency in first random d columns
g=zeros(1,N)
function dy = ODE(t,y)
for i=1:N
sum=0;
for j=1:N
if y(j)<0
g(j)=0
else
g(j)=1
sum=sum+(w(i,j)*g(j)
end
dy(i) = -y(i)+sum-tau(i);
end
endfunction
[t,y]=ode45(dy,t,1);
Réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!