function current=vstimulate(pre, frequency, gain, scaling, varargin) % % VSTIMULATE % % CURRENT = VSTIMULATE(PRE, FREQUENCY, GAIN, SCALING) % outputs a pulse of 100mV and 1 msec on the PRE % channel at FREQUENCY and returns whatever it % finds on both the channels. GAIN and SCALING % need to be specified, otherwise 1 (V/nA) and % 100 (mV/V) are assumed. Uses VSTIM to % actually deliver the stimulus. % % CURRENT = VSTIMULATE(PRE, FREQUENCY, GAIN, SCALING, NREPEAT) % repeats the above operation NREPEAT times. % if pre == 1 post = 2; else pre = 2; post = 1; end if frequency <= 0 frequency = 1000; end if gain <= 0 gain = 1; % the output gain of the amp, in V/nA end if scaling <= 0 scaling = 100; % the input scaling of the amp, in mV/V end if nargin==5 n=varargin{1}; else n=1; end mV=100; % amplitude of the pulse (in mV) pulse=mV*[zeros(0.2*frequency,1); ones(10,1); zeros(0.8*frequency - 10,1)]; nothing=zeros(frequency,1); stim=zeros(frequency,2); stim(:,pre)=pulse; stim(:,post)=nothing; current = vstim (stim, scaling, gain, frequency, n);