Trying to get magnitude of freq domain

Hi im new to matlab and im trying to figure out what i am doing wrong or how to do this correctly. - find and sketch the time-domain waveform and frequency-domain magnitude spectrum of the bandpass signal x(t)=sinc(100t) cos(400t).
heres what i have :
w1=100; w2=400*pi; t=[0:.001:.05]; x= sinc(w1*t).*cos(w2*t); %plot(t,x) wmin = -20; wmax = 20; w = {wmin,wmax,}; ffplot(x,w)

Answers (2)

How about this:
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
format compact;
w1=100;
w2=400*pi;
t=[0:.0001:.05];
x= sinc(w1*t).*cos(w2*t);
subplot(2,1,1);
plot(t, x, 'b-');
grid on;
title('The Time Domain Signal', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
theSpectrum = fft(x);
subplot(2,1,2);
plot(fftshift(real(theSpectrum)));
grid on;
title('The Real Part of the Spectrum', 'FontSize', fontSize);
Youssef  Khmou
Youssef Khmou on 11 Feb 2013
Edited: Youssef Khmou on 11 Feb 2013
hi, Aaron,
The response that "ImageAnalyst" gave is correct but it shows wrong frequencies,
Here is the code to produce the two figures :
w1=100;
w2=400*pi;
t=[0:.001:.05];
x= sinc(w1*t).*cos(w2*t);
figure, plot(t,x) , title (' Time Domain'),
Fs=1/.001 % From your time axis but also it must satisfy the Nyquist %condition which is Fs > 2* max(F) your max frquency is F=200 Hz
L=length(x);
N=ceil(log2(L));
fx=fft(x,2^N)/(L/2);% when you use 2^N the finit ft becomes fast .
Power=fx.*conj(fx);
f=(Fs/2^N)*(0:2^(N-1)-1);
figure,
plot(f,sqrt(Power(1:2^(N-1))),'r'),
xlabel(' Frequency (Hz)'),
ylabel('|F(Y)|'),
title(' Amplitude Spectrum'), grid on;

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Asked:

on 10 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!