Create model with input of variable size

Hello everyone,
I'm trying to create a simple model with a input that should be an array with size determined by a parameter that can be changed for any istance of the referenced model.
I have tried different things but I'm still not able to create it and i havent' found nothing similar into documentation.
Anyone has advice for this kind of problem.
Best regards.
Claudio

6 Comments

Be specific, not vague, at least if you want good help. There must be dozens of tools in MATLAB that can work with a "model" in some form, in as many ways. Explain what you are doing, far more clearly. Wha tool are you using? Is this a question about Simulink? Or perhaps a regression model of some form?
I'm just using simulink, i have a block into my custom library that accept as input one array of boolean with size not defined by the blocks but only by the "user".
I want to create the same behaviour with a normal model instead of a library block
How will the block accept the input? From Workspace? From File? Constant Block with parameter set() by a MATLAB script?
The input in the model is an inport that must be filled by the root model who will reference it. The root model could connect to that input a constant, a parameter, or a root inport. The final scope is C code generation
Hello,
Based on your description, a bounded variable-size signal seems like the right approach. Configure the referenced model Inport as variable-size and specify an upper bound. This allows the root model to provide arrays of different lengths while remaining compatible with C code generation. Unbounded variable-size signals are not supported for C code generation.
Documentation:
Hope this helps.
Hello,
thank you for your answer.
I have tried the approach you adviced but i found this limitation: if i instance the model into another model and i want to fix the array size using an inport to that instance, Simulink ask me to use variable-size inport even if i would like in that case to fix it. The only way to have it fixed, seems to connect the input of the referenced models a constant.
Is there any way to use inpoirt with fixed size?

Sign in to comment.

Answers (0)

Categories

Products

Release

R2024a

Asked:

on 7 Jul 2026 at 11:26

Commented:

on 13 Jul 2026 at 10:15

Community Treasure Hunt

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

Start Hunting!