*kf
by An Uncommon Lab

struct2bus

Converts a MATLAB structure, s, to a Simulink Bus Object with name, bus_name, in the base workspace or as an output. This is useful, for instance, when a Simulink Constant block contains a MATLAB structure, and this structure is passed into a MATLAB block. A bus can be created for the structure, and then the block output can be set to the generated bus type.

 bus = struct2bus(s)
 struct2bus(s, bus_name)

This function is used by the *kf engine when it creates Simulink models for filters which may have struct inputs.

The generated buses will have only real signals and constant sampling times. It will take the data type from each field, but is not meant to handle every possible data type that MATLAB's very flexible structures can store, handling instead only basic types like 'double' and 'uint8'.

Inputs

s

MATLAB structure containing basic numerical types

bus_name

Name for bus object (only used when there are no outputs)

Outputs

(none)

bus_name will exist in the base workspace

bus

The constructed bus object

Example

constants.F_km1 = eye(2);
constants.H_k   = [1 0];
struct2bus(constants, 'bus_filter_constants');
my_bus = struct2bus(constants); % same as above, but stored in my_bus.

Table of Contents

  1. Inputs
  2. Outputs
  3. Example