Clear Filters
Clear Filters

apply an array of data repeatedly to a signal in simulink

22 views (last 30 days)
Hey all, I was hoping on getting some insight about how to handle a situation like this, im having some trouble explaining it so ill try and make it clear and simple. If i have a 201 element array of values that correspond to a timespan of 20 seconds. How can i use that repeatedly in a running simulink model. Like have a source that on a trigger, starts adding the array values to another signal starting from the 0th element and reaching the 201s one after 20 seconds in simulation time. and whenever the trigger occurs it resets back to the zeroth element.
I know this isnt super specific, ive been trying to think of a way to do this and have been having trouble, is this something i should approach with a matlab function block that has an input for a trigger and the simulation time, then if the trigger signal comes in, reset the index for the output data array to zero, and whenever the simulation time increases by 0.1 of a second, increment the index and output that index off the data array.
I guess how would i supply the simulation time to a matlab function if this is the best solution? Or if theres an alternative way of accomplishing this, thanks
  2 Comments
Mathieu NOE
Mathieu NOE on 28 Mar 2023
hello
why not using a resetable counter ? connect its output to a look up table block (the table is initialized in a script )
Leo Rogers
Leo Rogers on 28 Mar 2023
This seems like a great avenue to pursue if there isnt a more direct avenue to take with a simulink block, thanks a bunch!

Sign in to comment.

Accepted Answer

Daniel
Daniel on 28 Mar 2023
Assuming your inputs are regularly spaced, you should be able to use a Repeating Sequence Stair block. You can specify the update rate as the sample time: e.g. if you want a new value every 0.1 seconds, set the sample time to 0.1.
  3 Comments
Daniel
Daniel on 28 Mar 2023
Ah, sorry I missed that nuance. I don't think there's a direct block for that, but you can put the repeating sequence inside a Resettable Subsystem. You may have to fiddle around with the reset block inside that subsystem to get it to respond properly to your trigger.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!