Hi. I want to generate a noise with a certain frequency, for example 10kHz but I do not know how to. So I just proceed with this code:
% Open standard demo sound that ships with MATLAB.
[perfectSound, freq] = audioread('music.wav'); noise = 0.1*randn(size(perfectSound));% Play noise
soundsc(noise, freq);% Get sampling frequency
t=0:1/freq:(length(noise)-1)/freq; figure(1);plot(t,noise);title('Noise');ylabel('Amplitude');xlabel('Length (in Second)');% Graph it
n=length(noise)-1;f=0:freq/n:freq;wavefft=abs(fft(noise));%perform Fourier Transform
figure(2);plot(f,wavefft);%plot Fourier Transform
xlabel('Frequency in Hz');ylabel('Magnitude');title('Noise FFT');
Then, result that I got is:
From workspace, the noise frequency is 44100 Hz. What should I do if I want to generate noise with different frequency?
Best Answer