The FIND block in Simulink is fixed size, but labeled as variable

I pass the vector [0; 0; 2; 0; 0; 2; 0; 0] (8x1) into the FIND block in Simulink. According to the documentation, the output should be the indices of the non-zero elements in the vector. This, by definition, would be a variable size, and the output is shown as variable size (thick dashed line instead of thin solid line). However, the size is 8 and not 2 as I expect it. The output is padded with 0's, so it is [3; 6; 0; 0; 0; 0; 0; 0].
The next step in my simulation is to pass it into an Embedded Matlab script. I configure the input port to be variable size, but when I run it, I get the error "Data is inferred as a variable size matrix, while its specified type is something else."
I tried using a selector block to pick out the first 2 values, but the output is exactly the same - variable size and padded with zeros.
Any advice on how to get the output of FIND into an EML script in Simulink successfully?

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 2월 8일

1 개 추천

The error that you get is "Data is inferred as a variable size matrix, while its specified type is something else." - which means that the block is able to infer that the input of of variable-size (which is correct), but you are specify it as a fixed-size signal. You can configure this setting by opening up the Embedded MATLAB Editor, then, select Tools>Edit Data/Ports. Select the corresponding input and check "Variable-size" on the right panel. Also, enter [8 1] as the Size (this is used as the maximum size for variable-size signals).

댓글 수: 1

Thanks. I had the "Variable-size" checked already, but I had not specified the size. That did the trick.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Event Functions에 대해 자세히 알아보기

제품

질문:

2012년 2월 8일

편집:

dpb
2013년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by