How to generate noise from 950 to 1050 Hz for 0.2 sec?

How to generate noise from 950 to 1050 Hz for 0.2 sec? Please help me.

2 Comments

How many elements do you want? Note that you should have at least enough to satisfy the Nyquist frequency. As long as you have that, you're free to have as many elements as you want define the 0.2 seconds. How about a million points?
I didn't answer. I asked clarifying questions. The answer(s) are below.

Sign in to comment.

 Accepted Answer

Choose Fs, generate broadband noise, filter with a bandpass:
Fs = 44100;
Tmax = 0.2;
Samples = Tmax*Fs;
noise = randn(Samples,1);
noise = bandpass(noise,[950 1050],Fs);
pspectrum(noise,Fs)

4 Comments

thank you for answering my question. but when I use this code, there is an error : noise = bandpass(noise,[950 1050],Fs);
Every time you have an error it is good to show the actually error message so we can now what actually happened. I would guess that either your matlab version does not have the function bandpass or you don't have the signal processing toolbox. The following solution should work in either case:
Fs = 44100;
Tmax = 0.2;
Samples = Tmax*Fs;
noise = randn(Samples,1);
% Take fft of the noise
fftNoise = fft(noise);
Freqs= [0:size(fftNoise,1)-1]/size(fftNoise,1)*Fs; % Freq Vector
% Get index for your Frequencies
[~,Pos950] = min(abs(Freqs-950));
[~,Pos1050] = min(abs(Freqs-1050));
% "zero out" all other bins
fftNoise(1:Pos950) = randn(Pos950,1)*1e-3;
fftNoise(Pos1050:end) = randn(size(fftNoise,1)-Pos1050+1,1)*1e-3;
% Get back time signal
noise = ifft(fftNoise,'symmetric');
figure,plot(Freqs,10*log10(abs(fft(noise))))
xlim([900,1200])
xlabel('Frequency [Hz]')
sound(noise,Fs)
Keep in mind that 0.2 s is almost nothing

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!