Hi,
I know this is a really basic question to post here, but I just can't figure out why my simple matlab code below isn't working!
I'm playing with FFT analysis and to run some tests I want to generate a sampled data set that is constructed from every fundamental frequency of each FFT bin.
I'm emulating sampled audio at 44.1K and want to generate a 2048 sample window.
I have defined the following variables:
fs = 44100; % sampling rate
sp = 1/fs; % sampling period
ns = 2048; % number of samples
br = fs/ns; % fft bin resolution = 21.5332 Hz
Therefore each FFT bin will center at multiples of 21.5332 Hz.
To generate the wave I'm using the loop below, but the resulting waveform has a nasty spikes at the beginning and end of the sample window:
y = zeros(1,ns);
% generate sample made up of the FFT bin centre ffrequencies
for i = br:br:fs/2,
y = y + sin(2*pi*i*[0: sp: ((ns1)*sp) ]);
end
I've attached a plot of (y). What am I doing wrong????
Thanks,
Vince.
I know this is a really basic question to post here, but I just can't figure out why my simple matlab code below isn't working!
I'm playing with FFT analysis and to run some tests I want to generate a sampled data set that is constructed from every fundamental frequency of each FFT bin.
I'm emulating sampled audio at 44.1K and want to generate a 2048 sample window.
I have defined the following variables:
fs = 44100; % sampling rate
sp = 1/fs; % sampling period
ns = 2048; % number of samples
br = fs/ns; % fft bin resolution = 21.5332 Hz
Therefore each FFT bin will center at multiples of 21.5332 Hz.
To generate the wave I'm using the loop below, but the resulting waveform has a nasty spikes at the beginning and end of the sample window:
y = zeros(1,ns);
% generate sample made up of the FFT bin centre ffrequencies
for i = br:br:fs/2,
y = y + sin(2*pi*i*[0: sp: ((ns1)*sp) ]);
end
I've attached a plot of (y). What am I doing wrong????
Thanks,
Vince.
Attachments

85.2 KB Views: 36