This snippet implements the very basic concepts of power computation of a given digital stream. It looks at total power, ac power and dc power. It also compares the results with the statistical parameters of variance and its square root (standard of deviation or std).
The example stream given is complex but the same rules apply to real vector by setting the imaginary element to zero.
clear all; %example vector having ac & dc power x = complex(randn(1,2048)+.2,randn(1,2048)-.1); %total power, three equivalent methods pwr1_total = mean(abs(x).^2); %mean of squared values pwr2_total = mean(real(x).^2 + imag(x).^2); pwr3_total = mean(x .* conj(x)); %total expressed as rms rms_total = sqrt(pwr1_total); %dc power pwr1_dc = mean(real(x))^2 + mean(imag(x))^2; %square of mean of values %ac power pwr1_ac = pwr1_total - pwr1_dc; %mean of squares - square of mean %relation of ac power to statistical variance pwr2_ac = var(x); %approximately %ac expressed as rms rms1_ac = sqrt(pwr1_ac); %ac relation to standard of deviation, std = sqrt(var) rms2_ac = std(x); %approximately %dc relation to variance pwr2_dc = pwr1_total - var(x); %approximately fprintf('----------------------------------------------------\r'); fprintf('power(total), : %1.5f, %1.5f, %1.5f\r',pwr1_total,pwr2_total,pwr3_total); fprintf('rms(total) : %1.5f\r',rms_total); fprintf('power(ac), variance : %1.5f, %1.5f\r',pwr1_ac,pwr2_ac); fprintf('rms(ac), std : %1.5f, %1.5f\r',rms1_ac,rms2_ac); fprintf('power(dc), (total-var) : %1.5f, %1.5f\r',pwr1_dc,pwr2_dc);
There are no comments yet!
Add a Comment