generate white noise signal with certain bandwidth?

조회 수: 5 (최근 30일)
ANAS HAMZAH
ANAS HAMZAH 2024년 11월 17일
댓글: Star Strider 2024년 11월 17일
i am trying to generate noise with 5uvrms and the frequncy bandwidth 100hz . then i want to add two noise block to calculate the total rms.
can any one help to generate this ?

답변 (1개)

Star Strider
Star Strider 2024년 11월 17일
The filtered signal iis no longer a white-noise signal, although the original signal is.
Try this —
Fs = 1000; % Sampling Frequency (Hz)
t = linspace(0, 1E4-1, 1E4).'/Fs; % Time Vector
ns = randn(1E+4, 1); % Noise Signal
nsf = lowpass(ns, 100, Fs, ImpulseResponse='iir'); % Filter Noise Signal
[FTns,Fv] = FFT1(ns,t); % Fourier Transform Of Original Noise Signal
[FTnsf,Fv] = FFT1(nsf,t); % Fourier Transform Of Filtered Noise Signal
figure
tiledlayout(2,1)
nexttile
plot(Fv, abs(FTns)*2)
grid
title('Original')
nexttile
plot(Fv, abs(FTnsf)*2)
grid
title('Filtered')
function [FTs1,Fv] = FFT1(s,t)
% Arguments:
% s: Signal Vector Or Matrix
% t: Associated Time Vector
t = t(:);
L = numel(t);
if size(s,2) == L
s = s.';
end
Fs = 1/mean(diff(t));
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));
Fv = Fs*(0:(NFFT/2))/NFFT;
% Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
Fv = Fv(:);
FTs1 = FTs(Iv,:);
end
.
  댓글 수: 3
ANAS HAMZAH
ANAS HAMZAH 2024년 11월 17일
using simulink blocks
Star Strider
Star Strider 2024년 11월 17일
You can also use —
Fs = 1000; % Sampling Frequency (Hz)
Fn = Fs/2;
Wp = 100/Fn; % Stopband Frequency (Normalised)
Ws = 101/Fn; % Passband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k);
t = linspace(0, 1E4-1, 1E4).'/Fs; % Time Vector
ns = randn(1E+4, 1); % Noise Signal
nsf = filtfilt(sos, g, ns); % Filter Noise Signal
[FTns,Fv] = FFT1(ns,t); % Fourier Transform Of Original Noise Signal
[FTnsf,Fv] = FFT1(nsf,t); % Fourier Transform Of Filtered Noise Signal
figure
tiledlayout(2,1)
nexttile
plot(Fv, abs(FTns)*2)
grid
title('Original')
nexttile
plot(Fv, abs(FTnsf)*2)
grid
title('Filtered')
function [FTs1,Fv] = FFT1(s,t)
% Arguments:
% s: Signal Vector Or Matrix
% t: Associated Time Vector
t = t(:);
L = numel(t);
if size(s,2) == L
s = s.';
end
Fs = 1/mean(diff(t));
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));
Fv = Fs*(0:(NFFT/2))/NFFT;
% Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
Fv = Fv(:);
FTs1 = FTs(Iv,:);
end
Unless you also have the DSP System Toolbox, you may need to use the transfer function implementation (b,a vectors) for this filter, instead of the second-order-section implemntation I use here. It is relatively straightforward to change my code to create that. See the documentation on ellip for that information.
Use the Signal Processing Toolbox filt2block function to create the block.
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Single-Rate Filters에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by