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

27 次查看(过去 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 CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by