How does Simulink Selector block work to extract dimension MxN matrix into 1xN row vectors?

조회 수: 33 (최근 30일)
Recently I was trying to take a 2x5 matrix signal and convert it into two 1x5 row vectors for further computation. To do so, I used the Simulink Selector block, and selected a 2 dimensional input (M of my MxN). Then to try and get just a row vector for dimension 1 and 2 respectively, I selected the Starting Index Option, and made sure that dimensional values were consistent (see image):
This setup works for the first row vector, but fails for the second row vector claiming the following error:
I eventually figured out how to split them into row vectors correctly via the following setup:
I am curious why the first setup works for the first row, but fails for the second row. Is this a bug, or do I have a fundamental misunderstanding of how this selector block is functioning? It seems odd that it would work in an inconsistent manner.
  댓글 수: 2
Bish Erbas
Bish Erbas 2018년 9월 24일
That's because when the Starting index (dialog) option is used, Simulink selects the elements based on the Index column and Output Size. Your input has only 5 columns. If you set Index to 2 and Output Size to 5, you are telling Simulink to select columns 2 3 4 5 6 (size of 5). If your goal is to extract the last 4 column elements in the 2nd row, you can set output size to 4. Result would be 7 8 9 10.
Jake Gonzalez
Jake Gonzalez 2018년 9월 25일
Aha! Based on this information, I made an edit to the input parameters and got the result I wanted.
Very Interesting. Thanks!

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 9월 24일
Are you sure? I tried as your example and there is no error. The error happened in "Selector1" yet the dialog show "Selector2" and "Selector3".
  댓글 수: 3
Jake Gonzalez
Jake Gonzalez 2018년 9월 24일
Wanted to link the Example model in case you wanted to look at exactly what I have.
Fangjun Jiang
Fangjun Jiang 2018년 9월 24일
The problem lies in the second dimension. The input is 2x5, so for the second dimension, if you starts with 2 but the output size is 5, then it requires 2x6 input. If you change the size from 5 to 4, then the error disappears.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by