# Matlab mixed IIR Filter

2 ビュー (過去 30 日間)
AndyK 2022 年 12 月 6 日

I need help to design the next IIR filter:
The input signal is composed of 1Hz and 30Hz sine waves. The signal sampling frequency is 100Hz and a total of 480 points are sampled. Signals below 7Hz are removed by the IIR.
There are 480 samples. Sample 0~159 are 30Hz sine waves, sample 160~319 are 1Hz sine waves and sample 320~479 are 30Hz sine waves.
I tried to do, but it looks not correct.
fs=100 % sampling frequency
f1=1
f2=30 % frequency of the signal
t=20 % time duration
n=[0:1/fs:t] % sample period
x1=sin(2*pi*f1*n) % single tone signal
subplot(3,1,1)
plot(n,x1)
x2=0.5*sin(2*pi*f2*n)
grid on
title('Sinusoidal signal');
% lssnew = merge(lss1,...,lssN)
z = [x1;x2]; % merge 2 signals
subplot(3,1,2)
plot(n,z)
Could someone give me an example how I can do it?
##### 2 件のコメント表示非表示 1 件の古いコメント
AndyK 2022 年 12 月 6 日
Thank you for your support. This is an example from the Holtek manual, which describes Cortex DSP programming. I want to design this IIR filter and then to compare Cortex DSP with Matlab filter. I have never worked with Matlab before and I'm going thru examples. Do you know how to combine these two signals (I need a function)

サインインしてコメントする。

### 採用された回答

Mathieu NOE 2022 年 12 月 6 日
hello
try this
this can be genralizd for a arbritary sequence of x1 / x2 signals
NB that a sampling frequency of 100 Hz is a bit low to reproduce a 30 Hz tone with a good accuracy ; would rather suggest to increase to 300 Hz at least fs=100; % sampling frequency
f1=1;
f2=30; % frequency of the signal
% t=20 % time duration
samples = 160 ; % for each block of data for 1 frequency
dt = 1/fs;
t = (0:samples-1)*dt; % sample period
x1=sin(2*pi*f1*t); % single tone signal
x2=0.5*sin(2*pi*f2*t);
figure
subplot(3,1,1)
title('Sinusoidal signal');
plot(t,x1)
subplot(3,1,2)
plot(t,x2)
grid on
z = [x1 x2 x1]; % merge 3 signals
tz = (0:3*samples-1)*dt; % time for 3 signals
subplot(3,1,3)
plot(tz,z)

サインインしてコメントする。

### カテゴリ

Find more on Single-Rate Filters in Help Center and File Exchange

R2022b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!