Programming Flashcards
(51 cards)
what is length() used for
returns the longest dimension of a vector or array
what does histcounts(data, bins) do
bins the data into discrete intervals and returns counts per bin
how do you calculate mean firing rate from spike times and time range?
mean firing rate from spike times and time range:
length(spike_times)/(end_time - start_time)
what is a cell array
a container that stores data of varying types and sizes using {}
how do you index a cell array to get the content
{row, col} instead of ()
what is the function of namean()
calculates the mean while ignoring NaN values
what is zscore(data) used for
standardizes data by substracting the mean and dividing by standard deviation
how do you plot a histogram of neuron activity with 5 second bins
how do you plot a histogram of neuron activity with 5 second bins
bin_edges = min(times):5:max(times);
histogram(times, bin_edges);
what does range(x) return
max(x) - min(x)
what is the difference between a matrix and a cell array?
matrices store only numeric data; cell arrays can store mixed types
how would you check if neuron 3 fired more than 1000 times?
if length(active_times{3}) > 1000
what function is used for PCA in matlab
pca()
what does subplot(1,2,1) do
creates a 1-row, 2-column subplot and activates the first one
what does sign(x) return
1 if x>0 and -1 if x<0 and 0 if x==0
how do you loop through all neurons in a dataset stored in a cell array
for i = 1:length(active_times)
how do you define a figure with multiple subplots
subplot(rows, cols, index) inside a for loop
whats a common mistake when using && in a vector comparison
&& only works on scalars, use & for vectors
what is the purpose of smoothdata()
applies a smoothing algorithm to reduce noise in data
what does fprintf(‘Rate: %f’, rate) do
printe the variable rate with formatting
why initialize vectors with nan()
to reserve space and handle missing values during loops
function to convert radians to degrees
rad2deg()
how do you find spikes within a time window
spikes(spikes > t1 & spikes < t2)
how do you apply a function to each cell in a cell array
cellfun(@function, cell_array)
what function do you use to generate random integers without replacement
datasample(vector, N, ‘Replace’, false)