📄 enerpwr.m
字号:
function p = enerpwr(x,d,T)
% ENERPWR Signal energy or signal power.
%
% Y = ENERPWR(X,D) computes the ENERGY in X(t).
%
% If X is a string of t, D=[dlow, dhi], the duration limits:.
% If X is a vector, D= [dlow, dhi, dt] includes the sampling interval.
%
% Y = ENERPWR(X,D,TP) computes POWER in periodic X(t) with period TP.
%
% ENERPWR (with no arguments) invokes the following example:
%
% % Find the power in a periodic signal whose one period is
% % 3*tri(t) over the duration (-1 1) and whose period is T=4
% >>pwr=enerpwr('3*tri(t)',[-1 1],4);
% ADSP Toolbox: Version 2.0
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998
if nargin==0,
help enerpwr
disp('Strike a key to see results of the example')
pause
pwr=enerpwr('3*tri(t)',[-1 1],4)
return
end
if any(nargin==[2,3]),
if length(d) < 2 & isstr(x),
error('D must be of the form [dlow, dhi]');
elseif length(d) < 3 & ~(isstr(x)),
error('D must be of the form [dlow, dhi, dt]');
end
if nargin==3
if T < abs(d(2)-d(1)),
error('Pulse width cannot exceed period')
return
end
end
if isstr(x),
y=['(' x ').*(' x ')'];
p=simpson(y,d(1:2));
else
p=sum(x.*x)*d(3);
end
if nargin==3,
p=p/T;
end
elseif nargin == 1,
error('Not enough input arguments');
elseif nargin > 3,
error('Too many input arguments');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -