rms of noise signal
Mostra commenti meno recenti
what i want to generate two RMS of noise signal and caculate the total RMS of the noise in simulink.
I tried to use 2 random number block to generate noise signal with vrms value 5uvrms i set the value of the variance 2.5e-11 of each block to achieve rms =5uvrms of each block then i did summation for these two blocks but the result not what I expected the result was 10e-6 rather than 7.071e-6.
if I did any mestaik or I used wrong tepology or block then please help me and show me the right way.
Risposte (1)
Mathieu NOE
il 14 Nov 2024
0 voti
hello
to get the correct result, you need two uncorrelated random generators. here you are using the same seed , so the two ouputs are the same and you double the signal (hence factor 4 on the variance)
change the seed in one of the rand generator and check signals are different
9 Commenti
ANAS HAMZAH
il 16 Nov 2024
Mathieu NOE
il 18 Nov 2024
hello again
the seed is what define how the random sequence is initilalized and generated
The seed is a starting point for a sequence of pseudorandom numbers. If you start from the same seed, you get the very same sequence
if you simply duplicate the same block with the same seed it will generate always the same signal (and that is NOT uncorrelated signals)
Mathieu NOE
il 18 Nov 2024
and if you use Band-Limited White Noise block, you have to remember that the rms value is given by :
rms = sqrt(noise power * ts)
the Band-Limited White Noise block dialog box ask you to define the noise power and the sample time (read the doc for more details)
ANAS HAMZAH
il 18 Nov 2024
Spostato: Walter Roberson
il 18 Nov 2024
Mathieu NOE
il 18 Nov 2024
that is starnge indeed - can you share your data as mat file
also , I am not aware of a "rms.m" matlab function - where does it comes from - or did you create it yourself ?
On my side I did exactly the same code but everything in the simulink file and I get the correct results (using your parameters)
the rms of the sum of the two signals appears in the red rectangle

Mathieu NOE
il 18 Nov 2024
I did the same as you , so I simply used simulink to generate the data and created a small m code for the rms computation - results are good on my side
code :
ts=5e-3;
rms = 5.0000e-06;
noise_pow = ts*(rms^2) % same NP in both blocks
seed1 = 0; % for gen #1
seed2 = 1; % for gen #2
% run the simulation
% load signals and compute rms
rms1 = myrms(out.out1)
rms2 = myrms(out.out2)
rms3 = myrms(out.out3) % summed signals
%%%%
function out = myrms(in)
out = sqrt(mean(in.^2));
end
results :
rms1 = 5.1509e-06
rms2 = 5.0434e-06
rms3 = 7.2256e-06 (sum)
ANAS HAMZAH
il 18 Nov 2024
Mathieu NOE
il 19 Nov 2024
hello again
attached my simulink file
the moving rms block contains simply 3 functions :
- square the signal
- low pass filter (first order recursive filter : out(k) = (1-alpha)*out(k-1) + alpha*in(k) , I choose alpha = 0.01 for 1000 samples long simulation. This replace the mean operand in the m code
- square root
Mathieu NOE
il 19 Nov 2024
NB that my simulink file shows the end value of the simulation, so the accuracy of the result depends on the alpha value and the simulation duration. The shorter the simulation the higher the alpha must be (to ensure that the low pass filter transient has vanished before end of simulation) and the less accurate the result will be.
when you do the math in m code with mean operand , you should get more accurate results IMO
Categorie
Scopri di più su Signal Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!