www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ApplyRationalTransferFunctionToMatrixExample.m
%% Filter Matrix Data % This example filters a matrix of data with the following rational transfer function: % % $$H(z) = \frac{b(1)}{a(1)+a(2)z^{-1}}=\frac{1}{1-0.2z^{-1}}$$ % %% % Create a 15-by-2 matrix of random input data. rng default %initialize random number generator x = rand(15,2); %% % Define the numerator and denominator coefficients for the rational % transfer function. b = 1; a = [1 -0.2]; %% % Apply the transfer function along the first dimension of |x| and return % the 1-D digital filter of each column. Plot the first column of original % data against the filtered data. y = filter(b,a,x); t = 0:length(x)-1; %index vector plot(t,x(:,1)) hold on plot(t,y(:,1)) legend('Input Data','Filtered Data') title('First Column') %% % Plot the second column 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 Column')