
clear all
clc

%Dados inseridos pelo usuario
activeplot = 1; %1 para plotar curvas VI
filename = '110316_1_ctrl_2.mat';
load(filename)

%%
aa = who('Trace*');
b = aa{1};
c = strfind(b,'_');

indsweep1 = b(c(1)+1:c(2)-1);
indsweep2 = b(c(2)+1:c(3)-1);
indsweep3 = b(c(3)+1:c(4)-1);
indsweep4 = b(c(4)+1:end);

eval(['t = Trace_' indsweep1 '_' indsweep2 '_1_' indsweep4 '(:,1);']);
raw_signal = [];
smooth_signal = [];
for j = 1:length(aa)
    eval(['raw_signal = [raw_signal Trace_' indsweep1 '_' indsweep2 '_' num2str(j) '_' indsweep4 '(:,2)];'])
    smooth_signal = [smooth_signal smooth(raw_signal(:,j),40)];
end

raw_signal = 1000*raw_signal;
smooth_signal = 1000*smooth_signal;

if activeplot == 1
    figure()
    plot(t,smooth_signal,'b')
    hold on
    xlabel('s')
    ylabel('mV')
end
