esca User’s Manual v1.2
exit
end
% check number of files and their names
basefilename = filename(1:end-8);
files = dir(strcat(pathname, basefilename, '*.dat'));
N = length(files);
% 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 2 columns (1 ch vc)
C = reshape(B(1:2*fix(length(B)/2)), 2, []);
D = C';
% select sampling frequency
display('Select bandwidth:');
display('1) 625 Hz');
display('2) 1.25 kHz');
display('3) 5 kHz');
display('4) 10 kHz');
sel = input('select 1,2,3,4: ');
switch sel
case 1
OSR = 1024;
case 2
OSR = 512;
case 3
OSR = 128;
case 4
OSR = 64;
otherwise
display('Error: invalid selection');
exit
end
Fs = 1250000 / OSR;
% return arrays
data = D(:, 1);
vc = D(:, 2);
time = (0:(length(vc) - 1)) * (1 / Fs);
% plot data
subplot(2,1,1)
plot(time, data)
grid on
xlabel('Time [s]')
ylabel('I [pA]')
subplot(2,1,2)
plot(time, vc)
grid on
xlabel('Time [s]')
ylabel('Vc [mV]')
end