I have a large binary related to 1 hour recording from 16 electrodes (each of them part of a "pair"). The binary data has in the file the following structure: 1 = time 2 = channel 1 3 = channel 2 ... 17 = channel 16
I am trying to loop fread in order to load a segment of 1 minute for each channel, perform some analysis, save a mat file and repeat with the following channel. The script works for a single channel using a while loop. I am trying to put the while loop nested in a for loop by setting the parameter "activepair" as variable from 1 to "total number of pairs in my data"
disp(sprintf('Processing minute: %d',index))
disp(sprintf('Processing pair: %d',activepair))
time = currData((1:(n_channels+1):end), 1);
data1= currData(((activepair+1):(n_channels+1):end), 1);
trace1 = [time data1];
seg1 = transpose(trace1(:, 2));
data2 = currData(((activepair+2):(n_channels+1):end), 1);
trace2 = [time data2];
seg2 = transpose(trace2(:,2));
if index > 59, break, end ;
However for some reason the script is not able to repeat. the variable currData results empty at the end of the first while loop and I receive an error related to the inconsistency of the matrix sizes used... I think somehow the reference to the beginning of the file... where fread should start, gets lost somewhere but I am not sure this is the issue.