Calculate the sum of two RMS values and theoretical RMS.

66 visualizaciones (últimos 30 días)
Michael
Michael el 17 de Feb. de 2023
Respondida: Rik el 17 de Feb. de 2023
2.19 Verify Equation 2.28 using simulated data. Generate two 1000-point random waveforms using randn. Make one waveform twice the amplitude of the other. Calculate the RMS of each, then add the two together and determine the RMS of this sum. Compare the RMS of the sum with the theoretical value determined by taking the square root of the sum of the two individual RMS values squared as predicted by Equation 2.28. Am I calculating xyRMS and tRMS correctly?
Code:
clear all;
close all;
clc;
N = 1000;
x = randn(1, N);
y = 2*randn(1, N);
z = x + y;
xRMS = sqrt(sum(x.^2)); % Evaluate the RMS value of x
yRMS = sqrt(sum(y.^2)); % Evaluate the RMS value of y
xyRMS = xRMS + yRMS; % Calculate the sum of RMS?
tRMS = sqrt(sum(x.^2)+sum(y.^2)); % Calculate the theoretical sum of RMS?
disp('RMS value of the two sums of RMS values:');
disp(xyRMS);
disp('Theoretical RMS value of the mean of two RMS sums combined:');
disp(tRMS);

Respuesta aceptada

Rik
Rik el 17 de Feb. de 2023
With vectors of the same size you shouldn't notice a difference, but you are calculating a root sum square, not a root mean square. Simply replace sum by mean and what you wrote looks fine.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by