I receive an error when adding a delay block in for loop block
Show older comments
Hi,
I am making a for loop. To make the variation in vector values visible on the scope, I have added a transport delay block after the iterator block as seen in the image below.

The problem, is that when I run the Simulink program, I receive an error which says:
'Loops_in_Simulink/For Iterator Subsystem/Transport Delay' has sample time 0. Sample time of block must be inherited (-1) because blocks in a triggered subsystem must run only when the triggered subsystem runs.
If I double click on the transport delay block, I cannot see an option to change the sample time. This program is not a homework task. Could someone let me know how I could change the sample time? Thanks in advance.
5 Comments
Stephen Eltinge
on 7 Dec 2022
Hi Matthew,
Can you post the full Simulink model you are working with, or at least a screenshot of the top-level model? Generally speaking, each step of the For Iterator Subsystem must finish running before the next one starts, so it's not entirely clear what purpose a Delay block would serve here.
Fangjun Jiang
on 7 Dec 2022
Edited: Fangjun Jiang
on 7 Dec 2022
Double click the block, click Help to bring up the document and example model.
Or, state your need and ask what block to be used.
I believe you misunderstood the "For Iterator" and "Transport Delay" block, completely.
Matthew Tieu
on 8 Dec 2022
Matthew Tieu
on 8 Dec 2022
Fangjun Jiang
on 8 Dec 2022
You are doing a 1:n for-loop. At the end of 1st loop, the value of output O(1) is obtained. At the end of 2nd loop, the value of output O(2) is obtained. You want "a delay of T seconds" between O(1) and O(2)??
But you should know, that in Simulink, all the for-loops, from 1 to n, are all calculated and finished in the same time step. There isn't a concept of "time delay" if your original problem is modeled and simulated this way.
If you want to insert some values between O(1) and O(2), then the "Vector Concatenate" block can be used.
But overall, I suspect that your original problem was modeled wrong. Your intended usage of the "For Iterator" block missed the mark. The output is a number (1 to N, depending on the loop) at the end of each loop. The output could be hidden (no ouptut at all). Please read the document to understand it.
Accepted Answer
More Answers (0)
Categories
Find more on Sources 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!