Effacer les filtres
Effacer les filtres

Variable Sized input bus in a MATLAB Function

10 vues (au cours des 30 derniers jours)
Hugo B
Hugo B le 12 Mar 2024
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 :

Réponses (1)

Nivedita
Nivedita le 2 Mai 2024
Hi Hugo,
Here are probably a few things you could try:
  1. 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.
  2. 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.
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!

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by