Code covered by the BSD License  

Highlights from
Bus X Struct

image thumbnail

Bus X Struct

by

 

12 Apr 2011 (Updated )

This example shows how to import Matlab Structs into Simulink by using BusObjects.

MyBusObjA()
% by Gustavo Baldo Carvalho
% (GustavoBaldoCarvalho@yahoo.com)
% 05/05/2011
% This files loads the Bus object MyBusObjA that defines the Bus A
% which receives the imported sub-struct A into Simulink.
% MyBusObjA is composed by:
%   - element Ael1.

function MyBusObjA() 
% MyBusObjA initializes a set of bus objects in the MATLAB base workspace 

% Bus object: MyBusObjA 
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'Ael1';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'double';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).SamplingMode = 'Sample based';

MyBusObjA = Simulink.Bus;
MyBusObjA.HeaderFile = '';
MyBusObjA.Description = sprintf('');
MyBusObjA.Elements = elems;
assignin('base', 'MyBusObjA', MyBusObjA)

Contact us