How to read a vectore in worksapce as a signal in Simulink with variable starting index
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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).
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!