Matlab mixed IIR Filter

3 vues (au cours des 30 derniers jours)
AndyK
AndyK le 6 Déc 2022
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?
Thank you in advance.
  2 commentaires
Askic V
Askic V le 6 Déc 2022
This is very unusual description of a problem. I assume you have samples in an array, so if you know for sure which samples are from sine waves 7 Hz or below (in this case 1 Hz), you just remove them from the array
samples_arr(161:320) = []
In Matlab, indexing starts with 1 and not 0 like in most other programing languages.
But if you need to design IIR filter, then I suggest you to check the following thread:
https://www.mathworks.com/matlabcentral/answers/284804-how-to-design-iir-highpass-filter-with-cutoff-frequency-of-20hz-and-fir-bandpass-filter-with-cutoff
AndyK
AndyK le 6 Déc 2022
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)

Connectez-vous pour commenter.

Réponse acceptée

Mathieu NOE
Mathieu NOE le 6 Déc 2022
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)

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by