2

I wrote a C S function which has a variable number of states depending on one parameter, which is passed to it (I'm using computational fluid dynamics and the parameter is the number of cells). I want to output a bus object from my S function that contains a temperature profile. Problem is I don't know the length of the output when I create the bus object in Simulink (in Bus Editor). Is there a way to dynamically set the size of the bus object from the C S function?

remus
  • 2,635
  • 2
  • 21
  • 46

1 Answers1

1

I think you can set the DimensionsMode property to "variable" instead of "fixed" (the default). See Simulink.BusElement and Variable-Size Signal Basics in the documentation for more details. Not sure how to code this in the S-function though.

am304
  • 13,758
  • 2
  • 22
  • 40
  • 1
    I switched my bus signal to Variable but the generated C code remains the same. It outputs a single value to that line instead of an array. I've thought of a way around: make an extra output port for the profile, which is not a bus. I can set the port width in this way when the simulation starts. And then convert it to a bus in Simulink. I would have preferred a block with a single output though. – remus Dec 02 '13 at 14:30