- use coder.varsize() in the ML Function block to define the variable temperature as variable length
- you should be able to feed the two signals into a switch block similar to what is shown in the example sldemo_varsize_basic. Type "sldemo_varsize_basic" at the MATLAB prompt to see the example.
Problem with variable-size signals (Simulink)
7 views (last 30 days)
Hey guys, I am facing some issues in a Simulink thermal-hydraulic code which deals with variable-size signals. The code is a bit complex but the problems are very easy to understand. They are two:
- I want to use a Matlab Function block which calculates the temperature (a single variable) in different nodes. The number of nodes - i.e. the length of variable temperature - is user-defined and fixed during the simulation. How can I define such a variable?
- My code needs to select either one Matlab Function block or another according to working conditions (calculated by the code itself in external blocks) to do some calculations. The two Functions have the same outputs - used then by the rest of the code - but with different dimensions (e.g. Matlab Function A calculates temperature in 5 nodes, Matlab Function B calculates temperature in 3 nodes). So, the size of the variable temperature is changing during the simulation. How can I define such a variable?
These are two different cases I need to solve. I tried by defining for a very basic Matlab Function block a variable-size signal using Model Explorer and flagging “Variable size”, but then I get the error “The sample time for any variable-size signal must be discrete” which I am not able to fix.
If you need more info, please let me know.
Thanks guys :)
Mark McBroom on 25 Feb 2022