3
$\begingroup$

First, I apologize for the vague title, to be honest, I'm not even sure how to describe my question in a title. If someone would like to edit it so its more reflective of what I'm asking, then please do.

I have simulink model running in real time gathering data and doing stuff in real time (1ms).

One of the things its doing is reading a signal from an external source. When the signal comes in, its in pretty bad shape, but if you look carefully, you can see that it "kinda" resembles the signal we are expecting. So some filtering should take care of it!

I collected some data and then started playing with the various filter options that matlab has, and I found one in the signal processing toolbox called filtfilt that works wonders. It pretty much pulls out the signal im looking for from the messy input signal. And it closely matches what the reference signal is. Win! (All this was done through a script).

Since our model is in simulink, I'd like to be able to simulate how the filter would work in a simulink environment so I created a function block with a tapped delay to "simulate" data coming in one sample at a time, it...does not work. Meaning the output does not look like my filter when ran through a script.

How can I get my simulink to behave like my script ?

This is actually my first time using simulink. I have used matlab in the past before for scripts but never simulink.

My filter is just

fc = 32; %cutoff freq
fs = 1000; %sample freq
fn = fc /(fs /2 ); %nyquist freq
pole = 12; %pole 
Av =7.6; %gain for butteworth
[b,a] = butter(pole,fn,'low'); %10 pole butterworth
lpf_out = Av*filtfilt(b,a,data); %apply filter

Reference Signal Reference Signal

Input Signal Input signal

Filtered signal Filtered Signal

$\endgroup$
  • $\begingroup$ Just note, that filtfilt is a noncausal filter!, thus cannot be introduced in simulink as is.... $\endgroup$ – Brethlosze Nov 14 '16 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.