: The Root Mean Square of a discrete-time signal is given by
We can easily calculate the RMS of signals in MATLAB using a combination of the sum, sqrt, and ^ commands. N represents the number of samples of the signal. Please note that the command .^ applied to a vector squares each element of the vector.
Write a script to calculate the RMS of the discrete-time signal x, defined as follows: n = a vector of number between -23 and 45 with increments of 0.1.
x = (n/2 + n3)./100
There is a function that calculates the rms in matlab (rms) compare the results of your formula with that of the native function.
n = [-23:0.1:45] % creating a vector
x = (n/2 + n.^3)./100
% finding rms using conventional method
vs = sum(x.^2);
rms1 = sqrt(vs / (numel(x)+1))
% finding rms using matlab function
rms2 = rms(x)
As we can see that the inbuilt formula and conventional method only hold true until the decimal precision starts. Inbuilts formula gives the rms value slightly larger than the conventional method.
Get Answers For Free
Most questions answered within 1 hours.