Create array (size) based on a variable/constant (Simulink)

조회 수: 43 (최근 30일)
Domi
Domi 2020년 4월 24일
댓글: VIGNESH BALAJI 2024년 1월 31일
Hey guys!
I have problems with simulink fixed sizes. I am trying to get a workaround for a problem.
So far I have a Matrix with is 200x2 in which I count all unique rows. The number of unique rows is the output of the function. This output is just a number.. e.g. 82. I want to use this output without the need of a matlab function block (bc it creates sizing errors coming from variable sizes and I want to work around this) to create a array with has the number of lines coming from the value of the unique output... so for example the output is 84. I want to create an array that is 84x2. The values of this array are not important.. can be random numbers or just 1 in every row.
I want to use this array for a (row) selector block to cut this 200x2 array into a new array which is Nx2 or from the example 84x2. Such that the numbers of rows are variable.
Is this possible? I could not find anything in the library. Any ideas? Or help would make my day because I am struggling with this whole variable size topic for over a week.
Cheers and best regards!

채택된 답변

Bhargavi Maganuru
Bhargavi Maganuru 2020년 4월 27일
Hi,
You can save the variable 'uni' to the workspace and try following steps to get variable size data out from the MATLAB function block as default is fixed size.
1. Select Edit Data in the MATLAB Function Block Editor.
2. Select the output signal for which you want to set the dimensions.
3. Enable the Variable Size check box and specify the size of the signal as [uni, 2]
Hope this helps!
  댓글 수: 2
Domi
Domi 2020년 4월 27일
Thanks.
VIGNESH BALAJI
VIGNESH BALAJI 2024년 1월 31일
This did not wokr for me and I got this error - Size definition is referring to the value of 'uni' which is not a constant, or a constant initialized from workspace.
I used this as a variable name to set max limit for the signal going out of matlab function block

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by