www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/ActiveNoiseControlOfARandomNoiseSignalExample.m
%% Active Noise Control of a Random Noise Signal %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject(x) becomes step(myObject,x). %% % Generate noise, create FIR primary path system model, generate observation % noise, filter the primary path system model output with added noise, and % create FIR secondary path system model. x = randn(1000,1); g = fir1(47,0.4); n = 0.1*randn(1000,1); d = filter(g,1,x) + n; b = fir1(31,0.5); %% % Use the Filtered-X LMS Filter to compute the filtered output and the % filter error for the input and the signal to be cancelled. mu = 0.008; ha = dsp.FilteredXLMSFilter(32, 'StepSize', mu, 'LeakageFactor', ... 1, 'SecondaryPathCoefficients', b); [y,e] = ha(x,d); %% % Plot the results. plot(1:1000,d,'b',1:1000,e,'r'); title('Active Noise Control of a Random Noise Signal'); legend('Original','Attenuated'); xlabel('Time Index'); ylabel('Signal Value'); grid on;