⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blocknormalize.m

📁 一种新的时频分析方法的matlab源程序。
💻 M
字号:
function [x,a]=blocknormalize(x)

% The function BLOCKNORMALIZE normalizes each block of the input signal, 
% as defined by zero crossings, to have a maximum amplitude of 1.
%
% Suggestion: if the routine is needed than use it with caution,
% since at least 2 problems have been encountered and corrected
% during the test: syntax error and envelope not flipped.
%
% Calling sequence-
% [x,a]=blocknormalize(x)
%
% Input-
%	x	- 2-D matrix data(npt,ncol) 
% Output-
%	x	- 2-D matrix of normalized data
%	a	- 2-D matrix of envelope
%
% Used by-
% 	FA

% Kenneth Arnold (NASA GSFC)    Summer 2003 Initial
% J.Marshak (NASA GSFC)		March 10, 2004 Modified
% 	(Corrected syntax error, flip envelope if data flipped)
% Kenneth Arnold (NASA GSFC) June 6, 2004 Tweaked

%----- Get the dimension
[npt,ncol] = size(x);

%----- Flip data if needed
flipped=0;
if (ncol > npt)
    x=x';
    [npt,ncol] = size(x);
    flipped=1;
end

%----- Initialize amplitude matrix
a = ones(npt,ncol);

%----- Process each column of data
for col=1:ncol
    i=1;
    while (i<=npt)
        blockSign = sign(x(i,col));
        while (blockSign == 0 & i < npt) % handle zero case
            i=i+1;
            blockSign = sign(x(i,col));
        end
        
	if (i==npt)
	   break;
	end

        blockExtr = 0; % extreme value (maximum or minimum)
        
        %----- Find the end of this block and its extreme value
        for (j=i:npt)
            cur = x(j,col);
            if (sign(cur) ~= blockSign)
                j=j-1;
                break;
            end
            if ((blockSign == 1 & cur > blockExtr) | (blockSign == -1 & cur < blockExtr))
                blockExtr = cur;
            end
        end
        
        if (blockExtr ~= 0)
            x(i:j,col) = x(i:j,col) / blockExtr * blockSign;
            a(i:j,col) = a(i:j,col) * blockExtr * blockSign;
        end
        
        i=j+1;
    end
end

%----- Flip data back if needed
if (flipped)
    x=x';
    a=a';
end

⌨️ 快捷键说明

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