MATLAB: Column-by-Column (SIMULINK)

iterationloopMATLABsimulinksimulink increment

Hey guys,
I would like to do a "slow" iteration..
As far as I know Simulink first executes a block and passes its value over. Which means, If I have a loop it finishes the loop and gives out the last value. But I need to give specific elements from my array as a command and send it. Which means I need to execute element 1 followed by element 2 in a ordered manner.
I would like to have sth like this pseudocode
A = 2×6 (like a constant block [1 2 3 4 5 6; 0 0 0 0 0 0])
for i = 1:6 do / or while loop
output col 1 of A
wait like 5 seconds or if-condition (like if trigger == 1 -> only(!) next col and wait for next trigger to output next col)
output col 2 of A
wait like 5 seconds or if-condition
output col 3 of A
..etc..
end loop
I already tried an assignment block.. but it outputs the full matrix
..and I tried direct look-up table... but I do not know how to get a right counter/incrementer for it.. sth like a triggered or slow incrementation..
In MATLAB you can write a pause and some commands in each loop step but a pause in simulink pauses the whole simulation and that is not what I want at all..
any tips?

Best Answer

You need the Selector block to capture the column you need, and then a Trigger Subsystem which executes on your command. You can also use a subsystem triggered by a function call. You can control the time delay between executions by using a Stateflow with the state transition 'after(5,sec)' for example, or implement an integrator block with gain 1, which will build up in real-time and you then trigger based on when it reaches a threshold.
You can also in Stateflow maintain a counter and increment with each sample time. Since you know your sample time, you can let the UDP Send trigger after the counter has reached a value.