rms of noise signal

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
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
ANAS HAMZAH il 16 Nov 2024
thank you so much thats work and if you don't mind can you explain to my what is the difference of using different seed.
and how i can do the same thing using Band-Limited White Noise block how i can convert the power noise to rms value to get total rms
Mathieu NOE
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
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
ANAS HAMZAH il 18 Nov 2024
Spostato: Walter Roberson il 18 Nov 2024
i tried to do the same concept using band limited white noise where I set
the first block 'A'
power noise Pn=Ts*(RMS^2)=1.25e-13,
Ts=5e-3.
seed=0
seconed block 'B'
power noise Pn=Ts*(RMS^2)=1.25e-13,
Ts=5e-3.
seed=1
which the RMS result of the first block=4.7227e-06 V
and the RMS result of the second block =5.385e-06 V
the result of the sumation =5.8367e-06 V which is wrong the result suppose to be squr(A^2+B^2)=7.071e-6
so where is the mistake ? if you can help me with that ?
Mathieu NOE
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
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)
there is a little difference between the result of the total rms in simulink and the mathimathical clculation and .
your sumlink result 7.436e-6
mathimathical clculation sqrt(4.9e-6^2+5.385e-6^2)=7.2806e-6
also the same problem when you use it in matlab and i don't why that's happend
about what i did in simulink i extruct the signals to matlab and i used the rms function that build in matlab but i have same issue.
after run the simulink file you can write this code in command windows to see the results :
noise_data = out.t2;
calculated_rms = rms(noise_data);
% Display the calculated RMS value
disp(['Calculated RMS of the noise signal: ', num2str(calculated_rms), ' V']);
note: when you change t2 to t,or t1 you will get there result. and if you dont mind to share your file to know how you build your RMS moving avr.
Mathieu NOE
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
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

Accedi per commentare.

Prodotti

Release

R2024a

Richiesto:

il 14 Nov 2024

Commentato:

il 19 Nov 2024

Community Treasure Hunt

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

Start Hunting!

Translated by