remove underscores from funktion names
This commit is contained in:
parent
a945268bee
commit
0e196d5e80
@ -1,6 +1,6 @@
|
|||||||
function [time, rate] = binned_rate(spike_times, bin_width, dt, t_max)
|
function [time, rate] = binnedRate(spike_times, bin_width, dt, t_max)
|
||||||
% Calculates the firing rate with the binning method. The hist funciton is
|
% Calculates the firing rate with the binning method. The hist
|
||||||
% used to count the number of spikes in each bin.
|
% function is used to count the number of spikes in each bin.
|
||||||
% Arguments:
|
% Arguments:
|
||||||
% spike_times, vector containing the times of the spikes.
|
% spike_times, vector containing the times of the spikes.
|
||||||
% bin_width, the width of the bins in seconds.
|
% bin_width, the width of the bins in seconds.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
function [time, rate] = convolution_rate(spike_times, sigma, dt, t_max)
|
function [time, rate] = convolutionRate(spike_times, sigma, dt, t_max)
|
||||||
% Calculates the firing rate with the convolution method.
|
% Calculates the firing rate with the convolution method.
|
||||||
% Arguments:
|
% Arguments:
|
||||||
% spike_times, a vector containing the spike times.
|
% spike_times, a vector containing the spike times.
|
||||||
% sigma, the standard deviation of the Gaussian kernel in seconds.
|
% sigma, the standard deviation of the Gaussian kernel
|
||||||
|
% in seconds.
|
||||||
% dt, the temporal resolution in seconds.
|
% dt, the temporal resolution in seconds.
|
||||||
% t_max, the trial duration in seconds.
|
% t_max, the trial duration in seconds.
|
||||||
%
|
%
|
||||||
@ -12,13 +13,13 @@ time = 0:dt:t_max - dt;
|
|||||||
rate = zeros(size(time));
|
rate = zeros(size(time));
|
||||||
spike_indices = round(spike_times / dt);
|
spike_indices = round(spike_times / dt);
|
||||||
rate(spike_indices) = 1;
|
rate(spike_indices) = 1;
|
||||||
kernel = gauss_kernel(sigma, dt);
|
kernel = gaussKernel(sigma, dt);
|
||||||
|
|
||||||
rate = conv(rate, kernel, 'same');
|
rate = conv(rate, kernel, 'same');
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function y = gauss_kernel(s, step)
|
function y = gaussKernel(s, step)
|
||||||
x = -4 * s:step:4 * s;
|
x = -4 * s:step:4 * s;
|
||||||
y = exp(-0.5 .* (x ./ s) .^ 2) ./ sqrt(2 * pi) / s;
|
y = exp(-0.5 .* (x ./ s) .^ 2) ./ sqrt(2 * pi) / s;
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function [time, rate] = instantaneous_rate(spike_times, dt, t_max)
|
function [time, rate] = instantaneousRate(spike_times, dt, t_max)
|
||||||
% Function calculates the firing rate as the inverse of the interspike
|
% Function calculates the firing rate as the inverse of the interspike
|
||||||
% interval.
|
% interval.
|
||||||
% Arguments:
|
% Arguments:
|
||||||
@ -6,7 +6,7 @@ function [time, rate] = instantaneous_rate(spike_times, dt, t_max)
|
|||||||
% dt, the temporal resolutions of the recording.
|
% dt, the temporal resolutions of the recording.
|
||||||
% t_max, the duration of the trial.
|
% t_max, the duration of the trial.
|
||||||
%
|
%
|
||||||
% Returns the vector representing time and a vector containing the rate.
|
% Returns two vectors containing the time and the rate.
|
||||||
|
|
||||||
time = 0:dt:t_max-dt;
|
time = 0:dt:t_max-dt;
|
||||||
rate = zeros(size(time));
|
rate = zeros(size(time));
|
||||||
|
@ -1174,7 +1174,7 @@ ab und liefert ein Ergebnis $y$ zur\"uck. Listing
|
|||||||
wird.
|
wird.
|
||||||
|
|
||||||
\begin{lstlisting}[caption={Funktionsdefinition in \matlab{}}, label=functiondefinitionlisting]
|
\begin{lstlisting}[caption={Funktionsdefinition in \matlab{}}, label=functiondefinitionlisting]
|
||||||
function [y] = function_name(arg_1, arg_2)
|
function [y] = functionName(arg_1, arg_2)
|
||||||
% ^ ^ ^
|
% ^ ^ ^
|
||||||
% Rueckgabewert Argument_1, Argument_2
|
% Rueckgabewert Argument_1, Argument_2
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
@ -1205,7 +1205,7 @@ Funktion, die eine Reihe von Sinusschwingungen unterschiedlicher
|
|||||||
Frequenzen berechnet und graphisch darstellt.
|
Frequenzen berechnet und graphisch darstellt.
|
||||||
|
|
||||||
\begin{lstlisting}[caption={Eine Beispielfunktion, die eine Reihe Sinusse plottet.},label=badsinewavelisting]
|
\begin{lstlisting}[caption={Eine Beispielfunktion, die eine Reihe Sinusse plottet.},label=badsinewavelisting]
|
||||||
function meine_erste_funktion() % Funktionskopf
|
function meineErsteFunktion() % Funktionskopf
|
||||||
t = (0:0.01:2); % hier faengt der Funktionskoerper an
|
t = (0:0.01:2); % hier faengt der Funktionskoerper an
|
||||||
frequenz = 1.0;
|
frequenz = 1.0;
|
||||||
amplituden = [0.25 0.5 0.75 1.0 1.25];
|
amplituden = [0.25 0.5 0.75 1.0 1.25];
|
||||||
@ -1256,7 +1256,7 @@ welche Daten sie zur\"uckliefern soll.
|
|||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item \codeterm{Name:} der Name sollte beschreiben, was die Funktion
|
\item \codeterm{Name:} der Name sollte beschreiben, was die Funktion
|
||||||
tut. In diesem Fall berechnet sie einen Sinus. Ein geeigneter Name
|
tut. In diesem Fall berechnet sie einen Sinus. Ein geeigneter Name
|
||||||
w\"are also \code{calculate\_sinewave}.
|
w\"are also \code{calculateSinewave}.
|
||||||
\item \codeterm{Argumente:} die zu brechnende Sinusschwingung sei durch
|
\item \codeterm{Argumente:} die zu brechnende Sinusschwingung sei durch
|
||||||
ihre Frequenz und die Amplitude bestimmt. Des Weiteren soll noch
|
ihre Frequenz und die Amplitude bestimmt. Des Weiteren soll noch
|
||||||
festgelegt werden, wie lang der Sinus sein soll und mit welcher
|
festgelegt werden, wie lang der Sinus sein soll und mit welcher
|
||||||
@ -1271,7 +1271,7 @@ Mit dieser Information ist es nun gut m\"oglich die Funktion zu
|
|||||||
implementieren (Listing \ref{sinefunctionlisting}).
|
implementieren (Listing \ref{sinefunctionlisting}).
|
||||||
|
|
||||||
\begin{lstlisting}[caption={Funktion, die einen Sinus berechnet.}, label=sinefunctionlisting]
|
\begin{lstlisting}[caption={Funktion, die einen Sinus berechnet.}, label=sinefunctionlisting]
|
||||||
function [time, sine] = calculate_sinewave(frequency, amplitude, t_max, t_step)
|
function [time, sine] = calculateSinewave(frequency, amplitude, t_max, t_step)
|
||||||
% The function calculates a sinewave with a given frequency and
|
% The function calculates a sinewave with a given frequency and
|
||||||
% amplitude.
|
% amplitude.
|
||||||
% Arguments: frequency, the frequency of the sine
|
% Arguments: frequency, the frequency of the sine
|
||||||
@ -1289,7 +1289,7 @@ function [time, sine] = calculate_sinewave(frequency, amplitude, t_max, t_step)
|
|||||||
Diese Aufgabe kann auch von einer Funktion \"ubernommen werden. Diese
|
Diese Aufgabe kann auch von einer Funktion \"ubernommen werden. Diese
|
||||||
Funktion hat keine andere Aufgabe, als die Daten zu plotten. Ihr Name
|
Funktion hat keine andere Aufgabe, als die Daten zu plotten. Ihr Name
|
||||||
sollte sich an dieser Aufgabe orientieren
|
sollte sich an dieser Aufgabe orientieren
|
||||||
(z.B. \code{plot\_sinewave}). Um einen einzelnen Sinus zu plotten
|
(z.B. \code{plotSinewave}). Um einen einzelnen Sinus zu plotten
|
||||||
werden im Wesentlichen die x-Werte und die zugeh\"origen y-Werte
|
werden im Wesentlichen die x-Werte und die zugeh\"origen y-Werte
|
||||||
ben\"otigt. Da mehrere Sinus geplottet werden sollen ist es auch
|
ben\"otigt. Da mehrere Sinus geplottet werden sollen ist es auch
|
||||||
sinnvoll eine Zeichenkette f\"ur die Legende an die Funktion zu
|
sinnvoll eine Zeichenkette f\"ur die Legende an die Funktion zu
|
||||||
@ -1297,7 +1297,7 @@ sinnvoll eine Zeichenkette f\"ur die Legende an die Funktion zu
|
|||||||
R\"uckgabewert ben\"otigt (Listing \ref{sineplotfunctionlisting}).
|
R\"uckgabewert ben\"otigt (Listing \ref{sineplotfunctionlisting}).
|
||||||
|
|
||||||
\begin{lstlisting}[caption={Funktion, die die Daten plottet.}, label=sineplotfunctionlisting]
|
\begin{lstlisting}[caption={Funktion, die die Daten plottet.}, label=sineplotfunctionlisting]
|
||||||
function plot_sinewave(x_data, y_data, name)
|
function plotSinewave(x_data, y_data, name)
|
||||||
% Plots x-data against y-data and sets the display name.
|
% Plots x-data against y-data and sets the display name.
|
||||||
% Arguments: x_data, the x-data
|
% Arguments: x_data, the x-data
|
||||||
% y_data, the y-data
|
% y_data, the y-data
|
||||||
@ -1329,9 +1329,9 @@ figure()
|
|||||||
hold on
|
hold on
|
||||||
|
|
||||||
for i = 1:length(amplitudes)
|
for i = 1:length(amplitudes)
|
||||||
[x_data, y_data] = calculate_sinewave(frequency, amplitudes(i), ...
|
[x_data, y_data] = calculateSinewave(frequency, amplitudes(i), ...
|
||||||
t_max, t_step);
|
t_max, t_step);
|
||||||
plot_sinewave(x_data, y_data, sprintf('freq: %5.2f, ampl: %5.2f',...
|
plotSinewave(x_data, y_data, sprintf('freq: %5.2f, ampl: %5.2f',...
|
||||||
frequency, amplitudes(i)))
|
frequency, amplitudes(i)))
|
||||||
end
|
end
|
||||||
legend('show')
|
legend('show')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function sines = calculate_sines(x, amplitudes, frequencies)
|
function sines = calculateSines(x, amplitudes, frequencies)
|
||||||
% Function calculates sinewaves with all combinations of
|
% Function calculates sinewaves with all combinations of
|
||||||
% given amplitudes and frequencies.
|
% given amplitudes and frequencies.
|
||||||
% Arguments: x, a vector of radiants for which the sine should be
|
% Arguments: x, a vector of radiants for which the sine should be
|
||||||
@ -12,12 +12,12 @@ function sines = calculate_sines(x, amplitudes, frequencies)
|
|||||||
sines = zeros(length(x), length(amplitudes), length(frequencies));
|
sines = zeros(length(x), length(amplitudes), length(frequencies));
|
||||||
|
|
||||||
for i = 1:length(amplitudes)
|
for i = 1:length(amplitudes)
|
||||||
sines(:,i,:) = sines_with_frequencies(x, amplitudes(i), frequencies);
|
sines(:,i,:) = sinesWithFrequencies(x, amplitudes(i), frequencies);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function sines = sines_with_frequencies(x, amplitude, frequencies)
|
function sines = sinesWithFrequencies(x, amplitude, frequencies)
|
||||||
sines = zeros(length(x), length(frequencies));
|
sines = zeros(length(x), length(frequencies));
|
||||||
for i = 1:length(frequencies)
|
for i = 1:length(frequencies)
|
||||||
sines(:,i) = sinewave(x, amplitude, frequencies(i));
|
sines(:,i) = sinewave(x, amplitude, frequencies(i));
|
@ -328,7 +328,7 @@ M\"oglichkeit sogenannte \codeterm{lokale Funktionen} oder auch
|
|||||||
erstellen. Listing \ref{localfunctions} zeigt ein Beispiel f\"ur eine
|
erstellen. Listing \ref{localfunctions} zeigt ein Beispiel f\"ur eine
|
||||||
lokale Funktion.
|
lokale Funktion.
|
||||||
|
|
||||||
\lstinputlisting[label=localfunctions, caption={\codeterm{Lokale Funktionen} erh\"ohen die Lesbarkeit sind aber nur innerhalb der definierenden Datei verf\"ugbar.}]{calculate_sines.m}
|
\lstinputlisting[label=localfunctions, caption={\codeterm{Lokale Funktionen} erh\"ohen die Lesbarkeit sind aber nur innerhalb der definierenden Datei verf\"ugbar.}]{calculateSines.m}
|
||||||
|
|
||||||
Lokale Funktionen existieren in der gleichen Datei und sind nur dort
|
Lokale Funktionen existieren in der gleichen Datei und sind nur dort
|
||||||
verf\"ugbar. Jede Funktion hat ihren eigenen G\"ultigkeitsbereich, das
|
verf\"ugbar. Jede Funktion hat ihren eigenen G\"ultigkeitsbereich, das
|
||||||
|
Reference in New Issue
Block a user