switch sel
case 1
range = 0;
case 2
range = 1;
otherwise
display('Error: invalid selection');
return
end
end
% read files
B = [];
for i = 1:N
fid = fopen(fullfile(pathname, files(i).name)); % open file for read
A = single(fread(fid, 'single')); % Array of single precision values
fclose(fid); % close file
B = [B;A];
end
% reshape data in an array with Nch+1 columns (Nch channels + vc)
C = reshape(B(1:(Nch + 1)*fix(length(B)/(Nch + 1))), (Nch + 1), []);
D = C';
% display final bandwidth
display(sprintf('Sampling rate = %.0f Hz', sampl / OSR));
display(sprintf('Bandwidth = %.0f Hz', PF * sampl / OSR));
% return arrays
data = D(:, 1:Nch);
vc = D(:, Nch + 1);
Fs = sampl / OSR;
time = (0:(length(vc) - 1))' * (1 / Fs);
% plot data
subplot(2,1,1)
ColOrd = get(gca,'ColorOrder');
[m, n] = size(ColOrd);
for i = 1:Nch
ColRow = rem(i, m);
if ColRow == 0
ColRow = m;
end
Col = ColOrd(ColRow,:);
plot(time, data(:, i), 'Color', Col)
hold on
end
hold off
grid on
xlabel('Time [s]')
if range == 0
ylabel('I [pA]')
else
ylabel('I [nA]')
end
subplot(2,1,2)
plot(time, vc)
grid on
xlabel('Time [s]')
ylabel('Vc [mV]')
end