このコードにIIRフィルターを組み込みたいです

5 visualizaciones (últimos 30 días)
IGUCHI REI
IGUCHI REI el 18 de En. de 2023
Respondida: Hernia Baby el 21 de En. de 2023
clear;
close all
Dat= load('output.txt');
t= Dat(:,1); %時間データをtに入れる
v= Dat(:,2); %電圧データをvに入れる
subplot(2,1,1)
plot(t,v)
title('Original Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ys = ylim;
subplot(2,1,2)
plot(t,filtered)
title('Lowpass Filtered Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ylim(ys)

Respuestas (2)

Hernia Baby
Hernia Baby el 21 de En. de 2023
せっかくなのでライブスクリプトのタスクを使います
fs = 1e3;
t = 0:1/fs:1;
v = [1 2]*sin(2*pi*[50 250]'.*t) + randn(size(t))/10;
■ここでタスクを使います
挿入 > タスク > フィルタ設計を選びます
■設定は以下のようにしました
■以下のコードは自動生成されます
% デジタル フィルターの設計
Myfilter = designfilt('lowpassiir', ...
'FilterOrder',5,'PassbandFrequency',100, ...
'PassbandRipple',1,'SampleRate',fs);
% 振幅応答と位相応答の可視化
freqz(Myfilter.Coefficients,[],fs)
■フィルタを掛けます
今回は filtfilt を使いました
filtered = filtfilt(Myfilter,v);
■図示します。
figure
subplot(2,1,1)
plot(t,v)
title('Original Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ys = ylim;
subplot(2,1,2)
plot(t,filtered)
title('Lowpass Filtered Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ylim(ys)

Atsushi Ueno
Atsushi Ueno el 21 de En. de 2023
Editada: Atsushi Ueno el 21 de En. de 2023
上記ローパスフィルタの事例を提示されたプログラムに当てはめてみました。
clear;
close all
fs = 1e3;
t = 0:1/fs:1;
v = [1 2]*sin(2*pi*[50 250]'.*t) + randn(size(t))/10;
filtered = lowpass(v,150,fs);
subplot(2,1,1)
plot(t,v)
title('Original Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ys = ylim;
subplot(2,1,2)
plot(t,filtered)
title('Lowpass Filtered Signal')
xlabel('Time (s)')
ylabel('電圧(V) ')
ylim(ys)

Categorías

Más información sobre デジタル フィルターとアナログ フィルター en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!