Get array size in Simulink
이전 댓글 표시
Hello,
I would like in Simulink have a block with an array as parameter. This array could have various size. In this code, I want to extract a specific element.
I tried to do this with a selector block to select the desired element and a size "Matlab function" to avoid an out of bounds conflicts.
However, the selector block needs to specify the input port size (wich is not always the same). Moreover, for example, for an array [10 12 17 20], how to extract the 4 from the 1x4 result of the size command?
Any idea?
댓글 수: 1
Azzi Abdelmalek
2012년 10월 18일
편집: Azzi Abdelmalek
2012년 10월 18일
Can you specify where your array is coming from. Is it an output of another block or it's just an input to other blocks. Is your array size changing during simulation?
채택된 답변
추가 답변 (2개)
javad sh
2015년 4월 22일
0 개 추천
I also used this method and found it useful\
I am reading from a serial port and i needed to know the length of massage that i am reading
now the problem that i have is this block will overflow if it become more than 255 what can we do when we have more than 255 byte to analysis
thank you for reply
fazareh
댓글 수: 1
Ali Bars Gunduz
2018년 10월 12일
You can use demux block to divide your array into 255 element arrays and compute each arrays lengths
카테고리
도움말 센터 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!