MATLAB Answers

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

49 views (last 30 days)
Domi
Domi on 24 Apr 2020
Commented: Domi on 27 Apr 2020
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!

  0 Comments

Sign in to comment.

Accepted Answer

Bhargavi Maganuru
Bhargavi Maganuru on 27 Apr 2020
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!

More Answers (0)

Community Treasure Hunt

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

Start Hunting!