Create array (size) based on a variable/constant (Simulink)
49 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!