iir matlab
时间: 2023-07-13 08:18:28 浏览: 81
IIR (Infinite Impulse Response) filters are digital filters that use feedback to create a response to an input signal. In MATLAB, you can design and implement IIR filters using the `butter`, `cheby1`, `cheby2`, `ellip`, and `besself` functions.
Here's an example of designing and applying a low-pass IIR filter to a signal:
```matlab
% Generate a signal
fs = 1000; % Sampling frequency
t = 0:1/fs:1;
x = sin(2*pi*50*t) + sin(2*pi*150*t) + sin(2*pi*300*t);
% Design an IIR filter
fc = 100; % Cutoff frequency
[b,a] = butter(6, fc/(fs/2));
% Apply the filter to the signal
y = filter(b,a,x);
% Plot the original and filtered signals
figure;
subplot(2,1,1);
plot(t,x);
title('Original Signal');
subplot(2,1,2);
plot(t,y);
title('Filtered Signal');
```
This code generates a signal that contains three sine waves, with frequencies of 50 Hz, 150 Hz, and 300 Hz. It then designs an IIR low-pass filter with a cutoff frequency of 100 Hz, using the `butter` function with a filter order of 6. Finally, it applies the filter to the signal using the `filter` function, and plots the original and filtered signals.
阅读全文