Problem with persistent variables within embedded function
古いコメントを表示
Hi,
I am currently implementing a second order lowpass filter as an embedded function and can be found as attachment. I tested it against a native simulink block employng the same state-space representation and the results are exactly, so the implementation itself should be correct.
My issue is the following: let's say that I have three signals that I intend to filter, hence I would be calling the following snippet:
sig1 = SecondOrderLowpassFilterTustin(u(1),fn,dn,Ts);
sig2 = SecondOrderLowpassFilterTustin(u(2),fn,dn,Ts);
sig3 = SecondOrderLowpassFilterTustin(u(3),fn,dn,Ts);
Unfortunately, this does not work as expected, and I assume that happen because of the persistent xs variable within the function. On the other hand, if let's say only u(1) was to be filtered, sig1 would be representing the proper results.
How can I make the function safe, so that the persistent variable are reset every time I call the function?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Event Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!