I am a little new to matlab and would like to get some help on how to write a program or a function that can calculate the energy/power of a signal depending on whether the signal is an energy or a power signal. Here is the program the I tried:
function [ ] = power_or_energy( s,t) %UNTITLED Summary of this function goes here % s is the input signal % t is the independent variable s2=s.^2; energy=int(s2,t,-inf,inf); if energy~=inf && energy~=-inf disp ('the signal is an energy signal with energy equal to ' ); disp(energy); end power=limit((int(s2,t,-t/2,t/2))/t,t,inf); if power~=inf && power~=-inf disp('the signal is a power signal with power equal to '); disp(power); end
But the problem here is that when i want to check it for a function like
t=0:0.01:10; s=sin(t); power_or_energy(s,t);
then i get the following error: "Undefined function 'int' for input arguments of type 'double'."
So how to i actually calculate the energy for such signals?
Also the above function works fine with the below input:
syms t; s=sin(t); power_or_energy(s,t);
Please help me in writing a function that can be used to find the energy of any input signal.