- Create a vector of the maximum size, and populate the remaining elemens with NaN (optionally). Maintain a list of the valid indices, in order to address the relevant elements only.
- Work with embedded Matlab function. You would still need to define the size of the vector, but maybe working directly with code would be easier to you.
- Track the execution order of the blocks, and add a unit delay, so you force the calculation of Nvec first.
Create a vector in Simulink
34 views (last 30 days)
I am trying to create a vector using constant block in simulink. My problem is that the size of the vector Nvec is calculated by the other blocks during the simulation. In other words, the size of vector Nvec is unknown before simulation starts. Therefore, I got the error "Undefined function or variable 'Nvec'" as I cannot use a unknown variable in defining the constant blcok. Any idea how to solve this issue, or, is there other ways to achieve my purpose.
Noam Greenboim on 31 Dec 2019
Simulink does not allow you the same freedom as Matlab, in terms of changing the size and type of parameters.
There are a few ways to approach it.