Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

find the mean, energy and power of cosine function

Asked by Passband Modulation on 21 Sep 2012
Latest activity Commented on by Walter Roberson on 18 Dec 2013

i am just a matlab beginner.

x[n]=2cos(0.2*pi*n) with a length of N =100 , that is, ,0<N<99 plotted

 clear all
 n=[0:99];
 x=2*cos(0.2*pi*n);
 stem(n,x);
 legend('x[n]');
 title('Sequence of 2*cos(0.2*pi*n)');
 xlabel('n');
 ylabel('x[n]');
 axis([0 99 -2 2]);

how to use MATLAB to compute the mean, and energy and power of x[n]given mean=x, energy=Ex and power=Px.

0 Comments

Passband  Modulation

Products

No products are associated with this question.

1 Answer

Answer by Wayne King on 21 Sep 2012
Edited by Wayne King on 21 Sep 2012
Accepted answer

You can just do:

      mean(x)
      Ex = norm(x,2)^2  % the energy 
      Px = 1/numel(x)*norm(x,2)^2 % power

If you don't want to use norm(), you just use sum()

      Ex = sum(abs(x).^2)
      Px = 1/numel(x)*sum(abs(x).^2)

Note that the RMS of the signal is

      sqrt(Px)

The Signal Processing Toolbox implements this as rms()

2 Comments

Passband Modulation on 21 Sep 2012

thank you very much, it works well!!

Walter Roberson on 18 Dec 2013

pinak parida commented,

power ,energy of a signal how norm works to be check?
Wayne King

Contact us