clear all

files = dir('*.dat');

data.names = {};
len = inf;
for k = 1:length(files)
    fileName = files(k).name;
    mote(k) = leggi_dat(fileName);
end

%%
data.start = datenum('15/06/2007  22:00:00','dd/mm/yyyy HH:MM:SS');
data.stop = datenum('26/06/2007  09:55:00','dd/mm/yyyy HH:MM:SS');
data.dt = datenum('Jan 0, 0000  0:00:30.0000');
data.T = zeros(length(mote),length(mote(1).temperature),'single');
data.tR = data.T;
data.aR = data.T;
data.H = data.T;

for k = 1:length(files)
    data.T(k,:) = mote(k).temperature';    
    data.tR(k,:) = mote(k).totalRadiation';    
    data.aR(k,:) = mote(k).activeRadiation';
    data.H(k,:) = mote(k).humidity';
    data.Ht(k,:) = mote(k).humidity_true';
    data.name(k,:) = mote(k).name;
end

%%
importa_posizioni()

for k = 1:length(n)
    pos = strmatch(n(k,:),data.name)
    if pos > 0
        data.p(pos,:) = p(k,:) 
    end    
end

%%
save data data

