kanachi
kanachi

Reputation: 45

How to find 3 hourly averages?

In the below code, each y is of 8 min duration. Once I generate the Powerr matrix I have what I Need but How do i do 3 hour averages? Should i do within the for loop or once I generate the Powerr matrix can i still be able to find out the 3 hourly averages of my data? thanks in advance.

    tic
    profile on
    warning('off','MATLAB:audiovideo:wavread:functionToBeRemoved');
        neglect_the_first_few= 5;
        lastfile = 10;
        Powerr = zeros(2049,10);
       count =[];
        parfor count = neglect_the_first_few + 1 :lastfile
    %         time_spectrum(timeindex) = timecount;
    warning('off','MATLAB:audiovideo:wavread:functionToBeRemoved');

    %         infiles = find(timestamp >= timecount & timestamp <= (timecount + timestep));
    %         if ~isempty(infiles)
    %            if isnan(time_spectrum)
    %                time_spectrum(timeindex) = NaN
    %            end
                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;
end

Upvotes: 0

Views: 59

Answers (1)

zlon
zlon

Reputation: 834

fr is independent from the parfor iteration count. So,this variable did not get transferred to the host from workers. Write fr(count)=...

You've done it correctly for Powerr.

Upvotes: 2

Related Questions