穿级计数法原理
穿级计数法是幅值域分析的常用方法,为单参数计数法,将整个载荷幅值范围分成等间距的若干级;通过统计信号采样点上升或下降时穿过某一级的次数,反映信号在各载荷水平的分布情况,如图所示。
MATLAB 代码
lcf.m
function [ lcf, thr ] = lcr( sig, thr );
% LCR calculates Level Crossing Rate, that is a number
% of crossings (in the positive direction) of an input
% vector through a given threshold vector.
% [ x, t ] = lcr( sig, thr );
%
% The crossings are calculated for all the values of the input threshold vector. The input signal has to be a vector.
% COMMENTS:
% The algorithm usues the Matlab matrix function instead of algorithm mased on definition of LCR.
% This algorithm is about 30 times faster than traditional (Matlab implementation).
% check errors:
if( (nargin~=2) | (ndims(sig)~=2) )
error( 'Wrong input parameters!' );
end
% calculate lcf for each threshold:
for i = 1:length( thr ),
tmp = ( sig > thr(i) );
tmp = diff( tmp );
lcf( i ) = sum( tmp==1 );
end
return;
例子
clear;clc;close all;
load Fs; % 输入数据
t = Fs(:,1); x = Fs(:,2);
% 增大幅值--针对存在负值的数据
s = min(x);s = abs(s);
x = x+s;
m = 50; % 载荷幅值的等分间距
y0=lcr(x,min(x):m:max(x));
figure(1)
t0=1:length(y0);
t0=t0*m;
plot(t0-s,y0,'k'); % 将图像平移回正确位置
代码参考:Level Crossing Rate - File Exchange - MATLAB Central (mathworks.cn)