このコードにIIRフィルターを組み込みたいです
Show older comments
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)
Answers (2)
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)
■フィルタを掛けます
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
on 21 Jan 2023
Edited: Atsushi Ueno
on 21 Jan 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)
Categories
Find more on Matched Filter and Ambiguity Function in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

