apply an array of data repeatedly to a signal in simulink

조회 수: 37 (최근 30일)
Leo Rogers
Leo Rogers 2023년 3월 27일
댓글: Leo Rogers 2023년 3월 29일
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.
Leo Rogers
Leo Rogers 2023년 3월 29일
Thank you so much, greatly appreciate the help!

댓글을 달려면 로그인하십시오.

추가 답변 (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