adding noise to a sine wave

조회 수: 7 (최근 30일)
mariam alsaid
mariam alsaid 2020년 11월 4일
답변: Samya 2023년 7월 7일
how can i Add a colored noise centered around 4.5kHz to a sinewave, and then plot noisy and filtered sine wave ?

답변 (1개)

Samya
Samya 2023년 7월 7일
To add colored noise centered around 4.5kHz to a sine wave and then plot the noisy and filtered sine wave, you can follow these steps in MATLAB:
  • Generate the sine wave:
fs = 44100; % Sampling frequency (adjust as needed)
t = 0:(1/fs):1; % Time vector
f = 1000; % Frequency of the sine wave (adjust as needed)
sine_wave = sin(2*pi*f*t); % Generate the sine wave
  • Generate colored noise:
noise_power = 0.2; % Adjust the noise power as needed
colored_noise = sqrt(noise_power) * randn(size(t)); % Generate Gaussian white noise
colored_noise = filter(1, [1 -0.9], colored_noise); % Filter the noise to make it colored (adjust filter coefficients as needed)
  • Add the colored noise to the sine wave:
noisy_sine_wave = sine_wave + colored_noise;
  • Plot the noisy and filtered sine wave:
filtered_sine_wave = filter(1, [1 -0.9], noisy_sine_wave); % Apply the same filter to the noisy signal
figure;
subplot(3,1,1);
plot(t, sine_wave);
xlabel('Time');
ylabel('Amplitude');
title('Sine Wave');
subplot(3,1,2);
plot(t, noisy_sine_wave);
xlabel('Time');
ylabel('Amplitude');
title('Noisy Sine Wave');
subplot(3,1,3);
plot(t, filtered_sine_wave);
xlabel('Time');
ylabel('Amplitude');
title('Filtered Sine Wave');
Hope this helps!

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by