How to generate random broadband vibration signal for certain frequency range ?

Hi,
How to generate random vibration signal for frequency range 0.5hz to 100Hz at 0.4 rms magnitude?
Thanks

 Accepted Answer

The usual approach is to generate a random signal (using either rand or randn) and then filter it —
Fs = 500; % Sampling Frequency (Hz)
t = linspace(0, 10, Fs*10)/Fs; % Time Vector
sv = randn(size(t)); % Input
vs = lowpass(sv, 100, Fs, 'ImpulseResponse','iir'); % Initial Vibration Signal
vs = highpass(vs, 0.5, Fs, 'ImpulseResponse','iir'); % Initial Vibration Signal
RMSvs = rms(vs); % RMS Of Generated & Filtered Signal
vs = vs * 0.4/RMSvs; % Scaled Result
Check = rms(vs) % Check Result
Check = 0.4000
figure
plot(t, vs)
grid
xlabel('Time')
ylabel('Amplitude')
L = numel(t);
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTvs = fft(vs,NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTvs(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
Creating a bandpass filter with such a low first cutoff frequency creates a filter with undesirable results. The cascaded lowpass-highpass filter approach works.
.

4 Comments

Thank you for reply, if i want to generate the vibration shaker using the output signal (example for 60 seconds at Fs = 2000). Do i need to loop it up to 60 seconds?. I used R2022b with NI analog output
I would just use a time vector that is 60 seconds long, and a signal corresponding to it.
The time vector is relatively easy to create, and this code for it is reasonably robust —
Fs = 2000; % Sampling Frequency (Hz)
Tlen = 60; % Signal Length (sec)
t = linspace(0, Tlen*Fs, Tlen*Fs+1)/Fs
t = 1×120001
0 0.0005 0.0010 0.0015 0.0020 0.0025 0.0030 0.0035 0.0040 0.0045 0.0050 0.0055 0.0060 0.0065 0.0070 0.0075 0.0080 0.0085 0.0090 0.0095 0.0100 0.0105 0.0110 0.0115 0.0120 0.0125 0.0130 0.0135 0.0140 0.0145
Check = [1/t(2), t(end)] % Check = [Sampling_Frequency, Final_Time_In_Seconds]
Check = 1×2
2000 60
It works most reliably when both ‘Fs’ and ‘Tlen’ are integers. Use the ‘t’ vector to create the signal.
.

Sign in to comment.

More Answers (1)

hello
here you are my friend !
Fs = 500; % sampling rate
duration = 10; % seconds
rms_amplitude = 0.4;
samples = Fs*duration;
% time vector
dt = 1/Fs;
time = (0:samples-1)'*dt;
signal = randn(samples,1);
%% band pass filter section %%%%%%
f_low = 0.5; % Hz
f_high = 100; % Hz
N_bpf = 4; % order
[b,a] = butter(N_bpf,2/Fs*[f_low f_high]);
signal = filter(b,a,signal);
% check rms value and correct it if needed
signal_rms = sqrt(mean(signal.^2)) % NOK
cor_factor = rms_amplitude/signal_rms;
signal = signal.*cor_factor;
signal_rms = sqrt(mean(signal.^2)) % OK
plot(time,signal,'b');

Asked:

amh
on 12 Apr 2022

Commented:

on 23 Feb 2023

Community Treasure Hunt

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

Start Hunting!