clear;
%ser = input('Please input series number:  ');
%fname = ['../cal/', ser, '.txt'];

%fname = '../../mmo130212/dat/MIA.lm';
%2nd Integration test
%fname = '../../mmo130514/dat/MIA.lm';
fname = '../../mmo130530/dat/MIA.lm';

dat= dlmread(fname, ' ');
n = size(dat);
ti = 0;
k1 = 1;
k2 = 1;
k3 = 1;
for i = 1:n(1)
    %MDPの時刻
    if dat(i, 2) == 9 & dat(i, 3) == 9 & dat(i,4) == 9 & dat(i,5) == 9
        mdpti = dat(i,1);
    elseif dat(i, 5) == 9999
        ti = dat(i,1);
    end
    if dat(i, 1) == 1111
        dat1(k1, 1) = ti;
        dat1(k1, 2:11) = dat(i,2:11);
        k1 = k1 + 1;
    end
    if dat(i, 1) == 1112
        dat2(k2, 1) = ti;
        dat2(k2, 2:11) = dat(i,2:11);
         k2 = k2 + 1;
    end
    if dat(i, 1) == 1113
        dat3(k2, 1) = ti;
        dat3(k2, 2:11) = dat(i,2:11);
         k3 = k3 + 1;
    end
    
end

figure(1);
subplot(3,1,1);
plot(dat1(:,1), dat1(:,2), 'rs','MarkerSize',4);
grid on;
%title('g-factor');
xlabel('MEAtime');
ylabel('VM(1)');

subplot(3,1,2);
plot(dat1(:,1), dat1(:,3), 'rs','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(2-4)');
hold on
plot(dat1(:,1), dat1(:,4), 'bs','MarkerSize',4);
plot(dat1(:,1), dat1(:,5), 'gs','MarkerSize',4);
hold off

subplot(3,1,3);
plot(dat1(:,1), dat1(:,6:11), 's','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(5-10)');

figure(2);
subplot(3,1,1);
plot(dat2(:,1), dat2(:,2), 'rs','MarkerSize',4);
grid on;
%title('g-factor');
xlabel('MEAtime');
ylabel('VM(1)');

subplot(3,1,2);
plot(dat2(:,1), dat2(:,3), 'rs','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(2-4)');
hold on
plot(dat2(:,1), dat2(:,4), 'bs','MarkerSize',4);
plot(dat2(:,1), dat2(:,5), 'gs','MarkerSize',4);
hold off

subplot(3,1,3);
plot(dat2(:,1), dat2(:,6:11), 's','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(5-10)');

figure(3);
subplot(3,1,1);
plot(dat3(:,1), dat3(:,2), 'rs','MarkerSize',4);
grid on;
%title('g-factor');
xlabel('MEAtime');
ylabel('VM(1)');

subplot(3,1,2);
plot(dat3(:,1), dat3(:,3), 'rs','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(2-4)');
hold on
plot(dat3(:,1), dat3(:,4), 'bs','MarkerSize',4);
plot(dat3(:,1), dat3(:,5), 'gs','MarkerSize',4);
hold off

subplot(3,1,3);
plot(dat3(:,1), dat3(:,6:11), 's','MarkerSize',4);
grid on;
xlabel('MEAtime');
ylabel('VM(5-10)');



