在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
了解这个函数,先看看这个基础知识:【 MATLAB 】Rational Transfer Function(有理传递函数) filter1-D digital filter Syntax
Description
If
针对这条语法举个例子: Moving-Average Filter移动平均滤波器是用于平滑噪声数据的常用方法。 此示例使用过滤器函数计算沿数据向量的平均值。 Create a 1-by-100 row vector of sinusoidal data that is corrupted by random noise. t = linspace(-pi,pi,100); rng default %initialize random number generator x = sin(t) + 0.25*rand(size(t)); A moving-average filter slides a window of length windowSize along the data, computing averages of the data contained in each window. The following difference equation defines a moving-average filter of a vector : For a window size of 5, compute the numerator and denominator coefficients for the rational transfer function. 对于窗口大小为5,计算有理传递函数的分子和分母系数。 windowSize = 5; b = (1/windowSize)*ones(1,windowSize); a = 1; Find the moving average of the data and plot it against the original data. 找到数据的移动平均值并根据原始数据绘制它。 y = filter(b,a,x); plot(t,x) hold on plot(t,y) legend('Input Data','Filtered Data')
举例说明: Filter Data in SectionsUse initial and final conditions for filter delays to filter data in sections, especially if memory limitations are a consideration. Generate a large random data sequence and split it into two segments, x = randn(10000,1); x1 = x(1:5000); x2 = x(5001:end); The whole sequence, Define the numerator and denominator coefficients for the rational transfer function, b = [2,3]; a = [1,0.2]; Filter the subsequences [y1,zf] = filter(b,a,x1); Use the final conditions from filtering y2 = filter(b,a,x2,zf);
Filter the entire sequence simultaneously for comparison. y = filter(b,a,x); isequal(y,[y1;y2]) ans = logical 1
举例: This example filters a matrix of data with the following rational transfer function. Create a 2-by-15 matrix of random input data. rng default %initialize random number generator x = rand(2,15); Define the numerator and denominator coefficients for the rational transfer function. b = 1; a = [1 -0.2]; Apply the transfer function along the second dimension of y = filter(b,a,x,[],2); t = 0:length(x)-1; %index vector plot(t,x(1,:)) hold on plot(t,y(1,:)) legend('Input Data','Filtered Data') title('First Row') Plot the second row of input data against the filtered data. figure plot(t,x(2,:)) hold on plot(t,y(2,:)) legend('Input Data','Filtered Data') title('Second Row')
这个形式的例子同: Output Arguments
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论