# Calculating energy of a signal using symbolic toolbox

3 views (last 30 days)
Aaron Connell on 16 Oct 2016
Answered: Gautam Mohan on 18 Oct 2016
I have two piecewise defined functions, x(t) and a reversed and shifted version of x(t) as shown below...I am supposed to use the symbolic toolbox in Matlab to calculate the energy of these two signals and explain how they are related. Not sure what the symbolic toolbox is...is it using syms function? Code for both signals is below.
% code
x = @(t) zeros(size(t)) +(t >= 0 & t < 2).*((1/2)*exp(t)) + (t >= 2 & t < 4).*(2*t-8);
t = linspace(0,6);
plot(t,x(t))
axis([-1 8 -4 4])
xlabel('Time(t)')
ylabel('x(t)')
title('Function x(t)')
% code
x = @(t) zeros(size(t)) +(t >= 0 & t < 2).*((1/2)*exp(t)) + (t >= 2 & t < 4).*(2*t-8);
f = @(t) x(-t-1);
t = linspace(-7, -1);
plot(t,f(t))
axis([-8 1 -4 4])
xlabel('Time(t)')
ylabel('f(t)');
title('Left shift and time reversal of x(t)')

Gautam Mohan on 18 Oct 2016
Hi Aaron,
The syms() function is indeed part of the Symbolic Toolbox. From my understanding, finding the energy of a signal involves taking the integral of its magnitude:
https://en.wikipedia.org/wiki/Energy_(signal_processing)
If you are supposed to use the symbolic function, I would suggest defining each function using piecewise() and then taking the integral of each after computing the magnitude -- both functions are available as part of the Symbolic Toolbox. Here are some links below to get started:
https://www.mathworks.com/help/symbolic/piecewise.html
https://www.mathworks.com/help/symbolic/int.html
Hope this helps!

### Categories

Find more on Code Performance in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!