- Make your bus object to allow for variable-size signals by setting the Dimensions property of each field to -1 and the DimensionsMode to Variable.
- Inside your MATLAB Function block, use coder.varsize to specify variable-size inputs and outputs. For example, coder.varsize('in', [1, Inf], [0, 1]); tells the compiler that in is a row vector whose size can change.
Variable Sized input bus in a MATLAB Function
5 次查看(过去 30 天)
显示 更早的评论
hello everyone,
i am in front of a difficulty, i searched many topics but i don't know what to do.
My objectiv : Be able to Generate the code in C++
My design :
1) I have an array of 4 lines and X row (Variable) going in a bus => This bus will get 4 field of X data (same row numbers for each)
example : Bus.in1 = [ 1 2 3 4 ] then the 3 others inputs of this bus will be an array of 4 elements.
2) This bus is going in a Matlab Function where i managed these data and it can produce a variable-sized array in output.
I found some elements but there is still some errors i don't know how to resolve :
What did i do :
1) My bus data are in variable "DimensionsMode" and i tried [1 Inf] as "Dimensions" in each field
2) My Input ports is in "Variable-size signal at Yes and i tried [1 Inf] as "Port Dimensions"
3) i don't know what to put as "Size" in my MATLAB Function input
4) MY MATLAB Function output is in "Variable Size" , and i don't know what tu put in "Size"
5) My MATLAB Function is checked for "Support variable-size arrays"
6) My configuration Simulation Target is in C++ and i checked the "Dynamic memory allocation in MATLAB functions"
The error i get sometimes is the following one :
0 个评论
回答(1 个)
Nivedita
2024-5-2
Hi Hugo,
Here are probably a few things you could try:
The error message you mentioned suggests an issue with the Bus Selector block or similar. Since not all blocks support variable-size signals, you may need to find alternatives or adjust how you're processing the data to avoid passing variable-size signals through unsupported blocks. The other settings you have mentioned seem to be correct, you can try out the above suggestions.
Hope they help resolve your issue!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!