I receive an error when adding a delay block in for loop block
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Tieu
am 23 Nov. 2022
Bearbeitet: Matthew Tieu
am 8 Dez. 2022
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 Kommentare
Fangjun Jiang
am 8 Dez. 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.
Akzeptierte Antwort
Stephen Eltinge
am 8 Dez. 2022
Bearbeitet: Stephen Eltinge
am 8 Dez. 2022
Hi Matthew,
Fangjun is correct in the comments above. Be careful not to confuse two different concepts: the timesteps of the top-level model and the iterations of the For Iterator Subsystem. At each model timestep, the For Iterator Subsystem executes its entire contents as many times as you specify, then reports the final output. The Display block does not update during this calculation.
It seems to me that what you are trying to do is construct a model that acts element-by-element on an array and prints some result to the Display block after every step. Instead, your current model processes the entire 1x31 array at every timestep and reports the same final answer. If you want to act on one element per timestep, you need to construct a time-varying signal. See the Signal From Workspace block for a simple way to import or construct a signal from raw data.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subsystems finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!