How to save a matrix to be able to use it in another m file
Show older comments
Hi there!
I have a m file which should create a 1x1000001 matrix (called RM03input1to1) of 1s and zeros (depending on the condition in the for loop). I'd like to somehow save that vector somewhere on my computer, then access that same vector (RM03input1to1) in another m file later. Here's my first m file that creates the vector:
function[isi] = OneNeuronFiring(frequency, dtPass, DPass, Amplitude)
tfin = 10000; %Final time value, in seconds
dt = dtPass; %timestep
vth = 1; %threshold voltage (once the neuron reaches this voltage, it fires)
vr = 0; %The reset voltage is 0 (after the neuron fires, its voltage goes back down to 0)
lif1data = []; %array of spike times (when the neuron fires) and relative spike time differences (time between 2 consecituve spike times)
tau = 1; %membrane time constant
A = Amplitude; %sinusoidal stimulus term (intensity of the dyad inputs)
vinit = 0; %voltage initial condition (starts at 0)
tlast = 0; %initialize last firing times
rads = frequency;
v = vinit;
D = DPass;
I = 0.9; %units of current divided by capacitance (bias to the cells. This gives a kick to the cells as they're reaching threshold voltage.)
a = 1;
b = 1;
RM03input1to1 = zeros(size(0:dt:tfin));
itercount = 1;
%main loop (LIF voltage change is measured, then the noise is added to the previous voltage)
for t=0:dt:tfin
noise = sqrt(2*D*dt)*randn();
dv = -v/tau + I*(1 + A*cos(a*rads*t) + A*cos(b*rads*t));
v = v + dt*dv + noise;
if (v >= vth)
tlast = t;
v = vr;
lif1data = [lif1data; t];
end
if (v >= vth)
RM03input1to1(itercount) = 1;
itercount = itercount + 1;
else
itercount = itercount + 1;
end
end
isi = diff(lif1data); %difference between consecutive spike times
any help on this would be greatly appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!