1
$\begingroup$

Given the following signal:

$$ x(n) = \left\{ \begin{array}{ll} u(0.01n-0.025)2.3704e^{(-0.287682n)}, & n\ge 0 \\ u(-(0.01n+0.025))2.3704e^{(0.287682n)}, & n< 0 \\ \end{array} \right. $$

I'm finding the energy using the summation formula:

$$E_{x(n)}=\sum_{n=-\infty}^\infty |x(n)|^2=\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(0.01n-0.025))^2+\sum_{n=-\infty}^0 (2.3704e^{(0.287682n)}u(-(0.01n+0.025)))^2 =\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(0.01n-0.025))^2+\sum_{n=0}^\infty(2.3704e^{(-0.287682n)}u(-(0.01n+0.025)))^2 = 2\times2.3704^2\times \sum_{n=0}^\infty (e^{(-0.287682\times 2)}u(0.01n-0.025))^n$$

So due to the sampling frequency and other information given about the problem, the sampling doesn't start until $n=3$ so I adjusted the limits of summation and removed the u(n) function:

$$=2\times2.3704^2\times \sum_{n=3}^\infty (e^{(-0.287682\times 2)})^n$$

And then adjusted the series to begin at $n=1$ so I could use the summation formula:

$$=2\times2.3704^2\times(\sum_{n=1}^\infty (e^{(-0.287682\times 2)})^n - (e^{(-0.287682\times 2)})^1 - (e^{(-0.287682\times 2)})^2)$$

So the series converges since the common ratio $<1$ and the sum of the series is:

$$S_{\infty}=\frac{a_1}{1-r}=\frac{(e^{(-0.287682\times 2)})^1}{1-e^{(-0.287682\times 2)}}=1.2857$$

Replacing the number above in the energy summation equation, I get:

$$E_{x(n)}=2\times 2.3704^2\times(1.2857-0.5625-0.3164)=4.5715$$

However, when I use MATLAB to find the energy of the signal using the following code:

E = 0
for i=1:fs+1
    E = E + abs(x(i))^2
end

where fs is the sampling frequency, the code yields the following result:

$$E=2.2858$$

which doesn't match my mathematical method. However, I noticed that the answer that MATLAB gives me is half the answer of what I got by hand. I also know with certainty that the MATLAB answer is correct.

So how do I go from $4.5715$ to $2.2858$? What's the step/reasoning that I'm missing?

Thank you!

$\endgroup$
3
  • $\begingroup$ Why do you calculate signal energy of fs+1 points? Shouldn't it be as long as possible? $\endgroup$
    – ZR Han
    Mar 26 at 6:04
  • $\begingroup$ @ZRHan because x() is a vector and vectors start their indices at 1 rather than 0 in MATLAB; x() is also the time-index vector in terms of n where n includes 0 so the +1 in the fs+1 line is to compensate for that $\endgroup$
    – Kevin KZ
    Mar 26 at 15:26
  • $\begingroup$ @ZRHan nvm, I just realized my error and what you mean. Thank you! $\endgroup$
    – Kevin KZ
    Mar 26 at 15:34
0
$\begingroup$

Since I don’t know rest of the given code, I’ve decided to calculate the energy other way round.

The MATLAB code for calculating the given function’s energy is given below:

syms n; % Symbol assignment for summation

Energy_1 = symsum(power((2.3704 * exp(0.287682 * n)), 2), n, -Inf, -3); % Energy for the left-hand side of the sample domain

Energy_2 = symsum(power((2.3704 * exp(-0.287682 * n)), 2), n, 3, Inf ); % Energy for the right-hand side of the sample domain

Energy = Energy_1 + Energy_2 % Overall energy

According to this code above, the resultant overall energy becomes $E = 4.5715$.

As the number of samples increases, the result gets accurate. Also, the coefficient in the exponential’s power affects the accuracy of the result too, but this is not the main case.

$\endgroup$
2
  • $\begingroup$ Ok I'm dumb I just figured out why; an issue with my code. The x(i) vector in my code contains the samples from -inf to +inf but i goes from 1 to half the samples, so it's only summing up half the samples, which obviously gives half the energy. I feel so stupid rn haha thank you for your help $\endgroup$
    – Kevin KZ
    Mar 26 at 15:33
  • $\begingroup$ @Kevin KZ That is okay, no problem. $\endgroup$ Mar 26 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.