Filtering of data in simulink
15 ビュー (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146204/image.png)
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 件のコメント
John Petersen
2014 年 11 月 24 日
what is your sample time? if t=[1:3597] that looks like 1s sampling. Maybe that's too slow for you system.
回答 (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.
参考
カテゴリ
Help Center および File Exchange で Array and Matrix Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!