% File: E2_125.M

% The average normalized power will be evaluated for a waveform that
% approximated a biased square wave using N harmonics of the Fourier
% Series where the Fourier Series coefficients are given by (2-114).

clear;

% Enter the Number of Harmomics to include in the F.S.
fprintf('Enter the number of Harmonics to use in the Fourier Series, N.\n');
N = input('N should be an odd integer: ');
if (rem(N,2) == 0)
  N = N+1;
end;

A = 5;
j = sqrt(-1);

for (n = 1:N)
  c(n) = A/(n*pi*j) * (sin(pi*n/2))^2;
end;

P = (A/2)^2 + 2*sum(c.*conj(c));

fprintf('\n\nThe average normalized power is %G Watts\n',P);





