在下面的代码中,每个y的持续时间为8分钟。一旦我生成了Powerr矩阵,我就拥有了我需要的但我如何做3小时平均值?我应该在for循环中做什么,或者一旦我生成Powerr矩阵,我仍然能够找出我的数据的3小时平均值吗?提前谢谢。
fid = fopen([directory '001/listing.txt'],'r');
tline = fgetl(fid);
ii = 0;
while (tline ~= -1)
if (length(tline) == 0)
continue
end
ii = ii + 1;
file_names(ii,:)=tline; % create file names in matlab data worksapace
year(ii) = str2num(tline(11:14));
month(ii) = str2num(tline(15:16));
day(ii) = str2num(tline(17:18));
hour(ii) = str2num(tline(20:21));
min(ii) = str2num(tline(22:23));
sec(ii) = str2num(tline(24:25));
tline = fgetl(fid);
end
fclose(fid);
timestamp = datenum(year,month,day,hour,min,sec);
%--------window applied is Hanning window--------
nfft = 4096; % |
hanning_window = hanning(nfft); % |
%-------------------------------------------------
timestamp = datenum(year,month,day,hour,min,sec);
tic
profile on
warning('off','MATLAB:audiovideo:wavread:functionToBeRemoved');
neglect_the_first_few= 5;
lastfile = 20;
Powerr = zeros(2049,20);
% fr = zeros(2049,1);
count =[];
parfor count = neglect_the_first_few + 1 :lastfile
warning('off','MATLAB:audiovideo:wavread:functionToBeRemoved');
y= [];
% for inputfile = infiles'
fn = [directory '/001/' file_names(count,:)];
[y,fs,nbits] = wavread(fn,'native');
disp(['sampling freq is ',num2str(fs),' hz. length of y is ',num2str(size(y)),'filenumber is ',num2str(count)])
% end
y = y- mean(y);
Y = double(y).*(1.49365435131571e-07);%CONVERSION - volts per bit for 24bit channel
% clear y;
nooverlap =[];%number of overlapped segments set to zero on Nov20th 2017
[Poww,fr] = pwelch(Y,hanning_window,nooverlap,nfft,fs);%no overlap taken into account%
Powerr(:,count) = Poww;
freq(:,count)= fr;
end