Create array (size) based on a variable/constant (Simulink)
49 views (last 30 days)
Show older comments
Domi
on 24 Apr 2020
Commented: VIGNESH BALAJI
on 31 Jan 2024
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
Accepted Answer
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!
2 Comments
VIGNESH BALAJI
on 31 Jan 2024
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
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!