Clear Filters
Clear Filters

How to use time varying structures in Simulink's embedded matlab

1 view (last 30 days)
I would like to manipulate a data structure inside of a Simulink Matlab Function, for example:
function y = fcn(data)
y = data.a + data.b;
where the number and names of the fields of the structure "data" are constant but the actual quantities inside of the fields are time varying. My understanding (and verified through dummy examples) is that the only way to reference an input data structure that is time varying in a Simulink embedded matlab function block is to use a Bus Object definition (as opposed to skipping the Bus Object and just using a bus creator block).
However, a driving constraint is that there can be more fields in "data" than just "a" and "b". Normally in Matlab this would not be a problem, the code above would just ignore any extra fields. However, in Simulink a Bus Object will not run if there are any extra fields in the input, even if they are not used.
Is there a way around this?
Thank you!
  1 Comment
dvd7e on 25 May 2018
Is this something that Matlab 2018a would address? In the release notes I see some items about variant buses, I'm not sure if that would be applicable or not

Sign in to comment.

Answers (0)


Find more on Simulink Functions in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!