%SPECBIN Creates a spectrogram of a binary file %Shane Crockett - 09JUN98 %For plotting spectragram of tatr data global f t B %Makes these variables available to all m.files filename = input('Binary filename to analyize? ','s'); % Asks user for name of signal to be analysized fid = fopen(filename); % Opens the specified signal % Reads the signal into g g = fread(fid, 'float'); % Calculates the spectrogram for the signal using 128 DFTs % Sample rate is approximately 50 Msamples per sec % Window sampling using a 128-point half cosine waveform (Hanning Window) % The window is shifted by 8 points (1/16th of the window) to allow for overlapping [X, f, t] = specgram(g,128,50*10^6,hanning(128),120); % Consider signal in terms of power B = X.*conj(X); % Scales Y Axis properly f = f + 25500000; % Plots the spectrogram as an image r = imagesc(t, f, log(B)); % Scales the data for mapping %Image plots from the top down, so it must be told to plot from the bottom up titl = ['Spectrogram of ' filename]; title(titl) xlabel('Time (sec)') ylabel('Frequency (MHz)') set(r, 'CDataMapping', 'scaled') set(gca, 'YDir', 'normal', 'YTicklabel', [30 35 40 45 50 55])%, 'XTickMode', 'manual', 'XTickLabel', [0 50 100 150 200 250 300 350 400]) set(gcf, 'Position', [50 25 400 350]) % Administrative to reduce memory clear X r fid %Defines the colormap and provides a colorbar load my5 colormap(my5); colorbar