# Filtering of data in simulink

조회 수: 15(최근 30일)
Andreas Volden 2014년 11월 24일
댓글: Andreas Volden 2014년 11월 26일
Hi! I have a matlab script which solves an LSE problem of the standard form: z = theta'*phi.
Since the equation have a derivative, I filter it using a first order filter. I've implemented the filters in Simulink, and the script calls this model to obtain filtered variables. Filters has to be identical.
The model uses variables from the script and is supposed to return the filtered variables. Time vector for this simulation is t=[1:3597]; The samples in delta_q_t and p_c_t are the same size(1:3597).
Problem is that my returned values don't match desired output(1x3597), they depend on the second denominator value(which is 5 is this pic). In the script i use the command: sim('model name',[1 n]); where n=3597.
Anyone who can help me? Another possibility is to add the filters straight into the script, but I'm not sure how to do this. Any help would be appreciated!
##### 댓글 수: 2표시 이전 댓글 수: 1숨기기 이전 댓글 수: 1
Andreas Volden 2014년 11월 25일
편집: Andreas Volden 2014년 11월 25일
Yes, my sample time is 1s. Problem is these are given, my known data for the problem; phi and z is given from an external file.
As stated in the question, I wan't my phi and z samples to be filtered using a first order stable filter. It could be as easy as 1/1+s. Is there an easy way to implement this directly in my script? Without using Simulink at all...

댓글을 달려면 로그인하십시오.

### 답변(1개)

John Petersen 2014년 11월 26일
A simple low pass filter (for scalar inputs - easily modified for vectors) is
y(i) = (alpha)* y(i-1) + (1-alpha)*x(i);
where alpha is between 0-1 depending on how much you want to filter. e.g. alpha = 0.99 is heavily filtered. If using an M-function block then you need to persist y or add a unit delay of y as another input. You could also do this with simulink blocks and not use a matlab function.
##### 댓글 수: 1표시 없음숨기기 없음
Andreas Volden 2014년 11월 26일
I'm not quite sure what you mean. Let me rephrase my problem if you bear with me here.
It is a least squares problem: I've got the equation k*p_dot = delta_q. Re-written into the linear parameter form of z = theta'*phi(z is p_dot, phi is delta_q and k is theta').
k is my unknown constant, I have samples for both p(not p_dot - to use derivative on p leads nowhere as the result is impossible to interpret) and delta_q. In order to get rid off p_dot I try to filter the equation by a stable filter lambda(s). The equation after laplace transform:
k(s)*p(s)*s=delta_q(s). The filter is lambda(s) and is simply set to s+1. The question is how do I implement this filter(s+1) in my equation?
All variables are vectors and sampling is [1:3597]
Thanks for your help either way!

댓글을 달려면 로그인하십시오.

### 범주

Find more on Signal Operations 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!

Translated by