Effacer les filtres
Effacer les filtres

apply an array of data repeatedly to a signal in simulink

22 vues (au cours des 30 derniers jours)
Leo Rogers
Leo Rogers le 27 Mar 2023
Commenté : Leo Rogers le 29 Mar 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 commentaires
Mathieu NOE
Mathieu NOE le 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 le 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!

Connectez-vous pour commenter.

Réponse acceptée

Daniel
Daniel le 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 commentaires
Daniel
Daniel le 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.
Leo Rogers
Leo Rogers le 29 Mar 2023
Thank you so much, greatly appreciate the help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by