Overview

At times, it may be useful to package a collection of processes and links into a Subsystem, for inclusion in larger systems. This has the advantage of convenient packaging, but can also offer encapsulation of the operation of a Subsystem under some interface. Building a Subsystem is exactly like building a system; in fact, it only really becomes a Subsystem when you add it to a larger system.

Procedure

  • Construct a parent system.
  • Add the previously constructed system to it as a Subsystem.
  • Link the output of the Subsystem to a process in the parent system.
  • Call brahms to execute the system.

Example

Script

This example, along with the others in this section, can be found in the script developing_systems.m in the support/tutorial/system/matlab folder.

M Source Code (against 995)
% section header disp([10 '=== Add Subsystem ===' 10]) % construct a parent system (and set its title) psys = sml_system('Parent System'); % add the original system to it as a Subsystem psys = psys.addsubsystem('sys', sys); % add a new process to the parent system cls = 'std/2009/resample/numeric'; fS = 10; state = []; state.order = 1; psys = psys.addprocess('resamp', cls, fS, state); % link the output of sys/dst to the input of resamp psys = psys.link('sys/dst>out', 'resamp'); % view the parent system psys % execute the system out = brahms(psys, exe); % view the system outputs out out.sys out.sys.src out.sys.dst out.resamp

Expected Output

Note that the outputs of sys are available in a sub-field sys of the output variable, out.

Matlab Console
=== Add Subsystem === -------------------------------- SystemML System -------------------------------- ['Parent System'] -------------------------------- ["sys", 'untitled'] "src" (std/2009/source/numeric) "dst" (std/2009/resample/numeric) ==> src>out ==> dst -------------------------------- "resamp" (std/2009/resample/numeric) ==> sys/dst>out ==> resamp -------------------------------- out = sys: [1x1 struct] resamp: [1x1 struct] ans = src: [1x1 struct] dst: [1x1 struct] ans = out: [1 2 3 4 5 6 7 8 9 10] ans = out: [0 0.42857 1.8571 3.2857 4.7143 6.1429 7.5714] ans = out: [0 0 0 0.042857 0.34286 1.1429 2.1429 3.1429 4.1429 5.1429]