In your code "X" contains the waveform information, not the frequency information. To get the frequency information of the soundfile you could use the FFT function. I use this (more elaborate, but still simple) code for what you want to do:
[FileName,PathName]=uigetfile('*.wav');
[y, Fs, nbits] = wavread(fullfile(PathName,FileName));
length_y=length(y);
NFFT = 2^nextpow2(length_y); % Next power of 2 from length of y
fft_y=fft(y,NFFT)/length_y;
f = Fs/2*linspace(0,1,NFFT/2+1);
semilogy(f,abs(fft_y(1:length(f))));
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
I hope this is useful to you. The plot will not be in steps like the one you have shown, but that can also be achieved - using the "stairs" plot function.