Filter löschen
Filter löschen

apply an array of data repeatedly to a signal in simulink

22 Ansichten (letzte 30 Tage)
Leo Rogers
Leo Rogers am 27 Mär. 2023
Kommentiert: Leo Rogers am 29 Mär. 2023
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 Kommentare
Mathieu NOE
Mathieu NOE am 28 Mär. 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 am 28 Mär. 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!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Daniel
Daniel am 28 Mär. 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 Kommentare
Daniel
Daniel am 28 Mär. 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.
Leo Rogers
Leo Rogers am 29 Mär. 2023
Thank you so much, greatly appreciate the help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by