MATLAB: Discrete fourier transform by matlab

dftdigital signal processingdoit4me

I would like to program
x(n)={10, 9,1,5,0,8,4} this function to X(ω)
I wanna know magnitude ofㅣX(ω)ㅣrepresented in ω-domain plot
please answer me the code of this program and I will appreciate so much
if you show me the capture or figure of plot .

Best Answer

x = [10 9 1 5 0 8 4];
xdft = fft(x);
plot(abs(xdft))
A better example would be something like:
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t)+randn(size(t));
xdft = fft(x);
freq = 0:Fs/length(x):Fs/2;
xdft = xdft(1:length(x)/2+1);
plot(freq,abs(xdft)), xlabel('Hz');
ylabel('Magnitude');