%PREWHITE Removes the carrier fequencies of a given spectrogram % Normalizes top 50% of frequencies based on power %Shane Crockett 10JUN98 %Integrates each frequency WRT time and chooses the top 50% of frequencys based on total power of that row. warning off %turns off warning for future divide by zero echo off [R C] = size(B); % Determines size of h int = mean(B,2); % Computes avg. power by determining the mean of each freq. bin (by summing num = 1:length(int); % each freq.bin and dividing by the # of elements in that bin.) int(:,2) = num'; % Assigns a number to each value of average power sort = sortrows(int,1); % Sorts the values of avg. power and arranges them in ascending order - based on first column sort = flipud(sort); % Rearranges values of avg. power into descending order x = round(length(int(:,1))/2); % Determines how many frequency bins will be normalized car = sort(1:x,2); % for n = car % Creates a matrix of the top 50% freq. bins based on avg. power pre = zeros(length(int),C); % row = B(n,:); % pre(n,:) = row; % end rB = reshape(B,1,R*C); msort = sortrows(rB'); mbar = median(msort); % Determines the median value for the entire spectrum normalize = mbar./mean(B')'; % Develops a matrix of normalized elements and replaces these normalized w = 1 - isnan(pre./pre); % freq bins into the original matrix. Zero is divided by Zero and a warning for k = num; % is generated but not displayed. prew(k,:) = normalize(k).*w(k,:); % end % supcar = B.*prew + isnan(pre./pre).*B; % New spectrum matrix with suppressed carriers %clear prew; % Erases PREW matrix warning on % Turns warnings back on % Administrative to free space clear R C B int num sort x car n pre row rB msort mbar w k prew normalize %PLOTS SPECTROGRAM OF PREWHITENED DATA prewspec titl = ['Prewhitened Spectrogram of ' filename]; title(titl)