Simulink: is there a way to only run a block once a (non-zero) signal arrives to it?

37 ビュー (過去 30 日間)
Hello world,
I'm doing some offline biosignal analysis on simulink. I pass an entire set of signals (e.g. 100 seconds of duration each) to Simulink and buffer them immediately (with buffer length corresponding to fs * 100 seconds). The idea is to perform a series of sequential signal processing operations on these 100-second frames rather than by considering each sample independently.
Let's say I have a signal processing block straight after this buffering. This processing block will essentially "run twice": the first time for the first 100 seconds where there is no signal (i.e there IS a "signal" but its a just a flat 0 line), and then the second time the next 100 seconds corresponding to the actual biosignals. Now this processing block includes a plot function and a send to workspace block. So what happens is that I'm plotting an empty plot and sending nonsense to the matlab workspace on the "first" time the preprocessing block is called.
So my question is: Is there any way to run a block ONLY when a buffered non-zero signal (which may also include SOME 0 elements)? Or, alternatively, is there any way to ensure these processing blocks only run when I'd like them to?
Thank you,
Rafael

採用された回答

Jonas
Jonas 2020 年 7 月 16 日
Use an Enabled subsystem and use a 'Compare To Zero' block to feed the enable port.
If you want the subsystem to only execute once, you can opt for a Triggered subsystem.
  1 件のコメント
Rafael Cordero
Rafael Cordero 2020 年 7 月 16 日
I used the enabled subsystem (didnt have to use the compare to zero block because if the enable input is a vector it will be considered 1 as long as there are SOME non-zero elements).
Thanks Jonas!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by