フィルターのクリア

How to read a vectore in worksapce as a signal in Simulink with variable starting index

1 回表示 (過去 30 日間)
Tanay
Tanay 2022 年 12 月 18 日
回答済み: Bharath Venkataraman 2022 年 12 月 19 日
Hello!
I am working on a Simulink project that requires me to read a vector stored in Matlab workspace as a signal. But the starting index of that signal is a variable. There is another block in simulink which gives an index number as an output. This is index from where Simulink is supposed to start reading the signal.
For example I have a discrete signal stored in matlab workspace in form of 10x1 vector.
If the simulink block gives an output 5, I have to read the signal starting from the 5th index all the way up to 10th index and then back to 1st index up to 4.
If the simulink block gives an output 7, I have to read the signal starting from the 7th index all the way up to 10th index and then back to 1st index up to 6.
I hope I was able to explain my doubt well.

回答 (1 件)

Bharath Venkataraman
Bharath Venkataraman 2022 年 12 月 19 日
I suggest using the MATLAB Function block for the index calculation. You can use the initial index and then compute the new index based on this initial index and the max index value (at which point you can switch back to an index value of 1).
You can use the computed index to access the array (loaded into a persistent variable).

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by