apply an array of data repeatedly to a signal in simulink

37 次查看(过去 30 天)
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 个评论
Mathieu NOE
Mathieu NOE 2023-3-28
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 2023-3-28
This seems like a great avenue to pursue if there isnt a more direct avenue to take with a simulink block, thanks a bunch!

请先登录,再进行评论。

采纳的回答

Daniel
Daniel 2023-3-28
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 个评论
Daniel
Daniel 2023-3-28
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by