i'm wondering oif someone can help, im trying to work through the following book:
Cohen, Mike X. MATLAB for Brain and Cognitive Scientists (MIT Press) (Page 490). The MIT Press. Kindle Edition.
This is a exact cut and paste of the code example given for modelling a simple intergrate and fire nueron, however everytime I run it I get a undefined error :(, from previous knowledge I know that usually undefined relates to calling a function which has not been explicitly declared. Problem is, i have no idea what either 'ti' or 'timevec' are supposed to relate to? (ive tried switching them to variable I have already declared, eg, 'time', but that just caused more issues!) Perhaps it's a syntax change that i've missed and quick fix? im using R2017b on OSX.
Thanks!
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);
end
r_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;