volt_rest = -70; % resting potential (mV)
volt_thresh = -50; % action potential thresh. (mV)
volt_reset = -75; % post-spike reset voltage
% membrane parameters
R_m = 10; % neuron membrane resistance (MOhm)
tau = 10; % time constant of decay (ms)
srate = 10000; % sampling rate in Hz
sim_dur = 1; % stimulus duration in seconds
time = 0:1/srate:sim_dur - 1/srate; input = zeros(1,length(time)); input(dsearchn(time',.3):dsearchn(time',.7)) = 3;neuronV = volt_rest + zeros(size(timevec));spiketimes = [];if neuronV(ti) > volt_thresh neuronV(ti) = volt_reset; spiketimes = cat(1,spiketimes,ti); endr_i = volt_rest + input(ti)*R_m; neuronV(ti+1) = r_i + (neuronV(ti) - r_i) * exp(-1000/srate/tau);neuronV(neuronV==volt_reset) = 40;
MATLAB: IAF Neuron simulation [Resolved]
MATLABneurosciencesyntax
Related Question
- Do I get an error about inductors connected together when simulating a model in ideal switching mode in SimPowerSystems
- How can i improve this code to bacame better more
- Do I receive incorrect results using the Breaker block from the Elements Library in SimPowerSystems 4.2 (R2006a) while simulating a DC circuit
- Ode23s gives different results when run inside for loop
- Internal loss equation currents in N-MOSFET device is cut off in the negative direction but not in the positive direction
Best Answer
I cannot tell you what is exactly written in that book, but a quick view of the code shows that timevec is same is time in your case. As for ti it is an index of the matrix so it can be defined in the following way.
This will remove all error.