Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
magnitude problem in DFT

Subject: magnitude problem in DFT

From: Kit Mai

Date: 23 Feb, 2012 01:40:16

Message: 1 of 4

hey guys,

I am new in DFT, and I am trying to analysize the distorted signal:

s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);

fd=60.32Hz;

Sample it using fs=5000Hz, N=1000

I used fft to get the spectrum, the frequency bins are correct, but the values returned from fft in matlab is not correct.

my code is:
fs = 5000; %Sampling frequency
T = 1/fs; %Sample time
N = 1000; %length of signal

fd = 60.32;

t = (0:N-1)*T;
s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
plot(t,s);

Y = fft(s,N); % DFT of sampled sequence
S = Y*T; % S(w) = T * Y(k)
f = fs/2*linspace(0,1,N/2+1);
figure;
stem(f,2*abs(S(1:N/2+1)));


The waveform spectrum shown in the paper is in the following liink:
http://www.ilovematlab.cn/forum.php?mod=attachment&aid=Nzk4MTJ8OTRlMmI1OGZ8MTMyOTk2MDQxN3w1MjYyNTl8MTYyNzkz¬humb=yes

I am wondering, how can I get the same spectrum as in the paper?

Subject: magnitude problem in DFT

From: Kit Mai

Date: 23 Feb, 2012 02:02:16

Message: 2 of 4

"Kit Mai" wrote in message <ji45e0$p8d$1@newscl01ah.mathworks.com>...
> hey guys,
>
> I am new in DFT, and I am trying to analysize the distorted signal:
>
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
>
> fd=60.32Hz;
>
> Sample it using fs=5000Hz, N=1000
>
> I used fft to get the spectrum, the frequency bins are correct, but the values returned from fft in matlab is not correct.
>
> my code is:
> fs = 5000; %Sampling frequency
> T = 1/fs; %Sample time
> N = 1000; %length of signal
>
> fd = 60.32;
>
> t = (0:N-1)*T;
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
> plot(t,s);
>
> Y = fft(s,N); % DFT of sampled sequence
> S = Y*T; % S(w) = T * Y(k)
> f = fs/2*linspace(0,1,N/2+1);
> figure;
> stem(f,2*abs(S(1:N/2+1)));
>
>
> The waveform spectrum shown in the paper is in the following liink:
> http://www.ilovematlab.cn/forum.php?mod=attachment&aid=Nzk4MTJ8OTRlMmI1OGZ8MTMyOTk2MDQxN3w1MjYyNTl8MTYyNzkz¬humb=yes
>
> I am wondering, how can I get the same spectrum as in the paper?



I noticed that the vertical-axis in the spectrum I attached is "amplitude p.u." what does it mean?

For some reason, I need to make the amplitude to be 1 when f=fd, 0.25 when f=3*fd, corresponding to the amplitude in time domain. How can I do this?

I guess the amplitude in this spectrum is not the true value of DFT, am I correct?

If so, then what are the true values of DFT?

Many thanks!
Kit

Subject: magnitude problem in DFT

From: Kit Mai

Date: 23 Feb, 2012 02:11:13

Message: 3 of 4

"Kit Mai" wrote in message <ji45e0$p8d$1@newscl01ah.mathworks.com>...
> hey guys,
>
> I am new in DFT, and I am trying to analysize the distorted signal:
>
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
>
> fd=60.32Hz;
>
> Sample it using fs=5000Hz, N=1000
>
> I used fft to get the spectrum, the frequency bins are correct, but the values returned from fft in matlab is not correct.
>
> my code is:
> fs = 5000; %Sampling frequency
> T = 1/fs; %Sample time
> N = 1000; %length of signal
>
> fd = 60.32;
>
> t = (0:N-1)*T;
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
> plot(t,s);
>
> Y = fft(s,N); % DFT of sampled sequence
> S = Y*T; % S(w) = T * Y(k)
> f = fs/2*linspace(0,1,N/2+1);
> figure;
> stem(f,2*abs(S(1:N/2+1)));
>
>
> The waveform spectrum shown in the paper is in the following liink:
> http://www.ouliu.net/r/201202231009112k6um.jpeg
>
> I am wondering, how can I get the same spectrum as in the paper?


Sorry, the previous link of spectrum is not working, here is the new link for the spectrum:

http://www.ouliu.net/r/201202231009112k6um.jpeg

Thanks guys, I am waiting.

Subject: magnitude problem in DFT

From: Greg Heath

Date: 23 Feb, 2012 16:38:05

Message: 4 of 4

On Feb 22, 8:40 pm, "Kit Mai" <maiwei...@hotmail.com> wrote:
> hey guys,
>
> I am new in DFT, and I am trying to analysize the distorted signal:
>
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
>
> fd=60.32Hz;
>
> Sample it using fs=5000Hz, N=1000
>
> I used fft to get the spectrum, the frequency bins are correct, but the values returned from fft in matlab is not correct.
>
> my code is:
> fs = 5000;    %Sampling frequency
> T = 1/fs;     %Sample time
> N = 1000;     %length of signal
>
> fd = 60.32;
>
> t = (0:N-1)*T;
> s = sin(2*pi*fd*t+23*pi/180) + 0.25*sin(2*pi*3*fd*t+68*pi/180) + 0.3*sin(2*pi*5*fd*t+16*pi/180) + 0.1*sin(2*pi*128*t+78*pi/180) + 0.15*sin(2*pi*243.2*t+94*pi/180) + 0.07*sin(2*pi*376*t);
> plot(t,s);
>
> Y = fft(s,N);   % DFT of sampled sequence
> S = Y*T;        % S(w) = T * Y(k)
> f = fs/2*linspace(0,1,N/2+1);
> figure;
> stem(f,2*abs(S(1:N/2+1)));
>
> The waveform spectrum shown in the paper is in the following liink:http://www.ilovematlab.cn/forum.php?mod=attachment&aid=Nzk4MTJ8OTRlMm...
>
> I am wondering, how can I get the same spectrum as in the paper?

Simplify

N=32, Fs = 2
dt = 1/Fs
t = dt*(0:N-1);
f0 = Fs/4
x = cos(2*pi*f0*t);
X = fft(x);
A = max(abs(X))

What factor is needed to get A = 1/2 ?

Hope this helps.

Greg

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us