1function m = mtrace_mean(trace, ntypes, type)
2% [m]=mtrace_mean(trace, ntypes, type)
5% Compute the mean of a trace, divided by types
8% trace - the array containing the trace data
9% ntypes - the number of different types
10% type - an array indicating the type of each element in the trace (0-indexed)
13% m - a column vector containing the mean values
for each type
15% Initialize mean vector
18% Compute mean
for each type
20 % Find indices where type equals c
23 % Compute mean only
for elements of
this type
24 m(c+1) = mean(trace(idx));
26 % If no elements of
this type, set to NaN