energies.m

来自「A MATLAB tool for analysis of Transient 」· M 代码 · 共 44 行

M
44
字号
function [E,sE]=energies(P,dt,ind,wid);

% ENERGIES calculates energy from time-dependent powerspectrum
%
%   [E,sE]=energies(P,dt,ind,wid);
%
%  in:  P       time-dependent power spectrum matrix
%       dt      time interval in milliseconds
%       ind     indexes of middle-frequencies (columns of P) (default all)
%       wid     numbers of columns to include in total energy 
%               rounded to next odd integer (default [1])
%
% out:  E       row-matrix of energies ([Ewid(1);Ewid(2);...;Ewid(n)])
%       sE      string matrix of energy-values (mPa^2 * ms)

% (c) Pekka Kumpulainen 21.11.1993 (P.K. 15.2.1995)

if nargin < 3; ind= 1:size(P,2); end
if nargin < 3; wid=[1]; end

nband=length(ind);
nwid=length(wid);
E=zeros(nwid,nband);

for iw=1:nwid;
  dc= floor(wid(iw)/2);
  for ib=1:nband;
    in=(ind(ib)-dc):(ind(ib)+dc);
    E(iw,ib)=sum(sum(P(:,in)));
  end
end

E=E*dt;

if nargout > 1;
  s=sprintf('%3.1f|',E(1,:)*1e9);
  sE=str2mat(s(1:(length(s)-1)));
  for ii=2:nwid;
    s=sprintf('%3.1f|',E(ii,:)*1e9);
    sE=str2mat(sE,s(1:(length(s)-1)));
  end
end    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?