% modified from jon's continuous VC heka data plotting script (07 April 2010)

fid = '20100629_3-11.mat';
loc = 'C:\Users\Lab_2\Desktop\mingfaifong\20100629\';
%data = load(strcat([loc fid]));

%N = 5; % number of plot rows

datid = fieldnames(data);
if length(datid) == 1
    dat = data.(datid{1});
end

time = dat(:,1);
ord = 10e11*dat(:,2);

%seglen = floor(length(time)/N);
seglen = 1200*1000; %in seconds; 900s = 15min; 1200s = 20min
N = ceil(length(time)/seglen);
ymin = min(ord)-50;
ymax = max(ord)+50;

figure()
for i = 1:N
    subplot(N,1,i)
    x = time((i-1)*seglen+1:i*seglen+1);
    y = ord((i-1)*seglen+1:i*seglen+1);
    plot(x,y,'k');
    ylabel('$I_{mem} (pA)$','Interpreter','latex');
    ylim([-1100 100])
    xlim([min(x) max(x)]);
    if i == 1
        title(fid,'Interpreter','none');
    end
    if i == N
        xlabel('$Time (s)$','Interpreter','latex');
    end
end

