In System Composer™, an architecture is fully defined by three sets of information:
You can import an architecture into System Composer when this information is defined in or converted into MATLAB® tables.
In this example, the architecture information of a simple UAV system is defined in an Excel spreadsheet and is used to create a System Composer architecture model. It also links elements to the specified system level requirement. You can modify the files in this example to import architectures defined in external tools, when the data includes the required information. The example also shows how to export this architecture information from System Composer architecture model to an Excel® spreadsheet.
You can characterize the architecture as a network of components and import by defining components, ports, connections, interfaces and requirement links in MATLAB tables. The
components table must include name, unique ID, and parent component ID for each component. It can also include other relevant information required to construct the architecture hierarchy for referenced model, and stereotype qualifier names. The
ports table must include port name, direction, component, and port ID information. Port interface information may also be required to assign ports to components. The
connections table includes information to connect ports. At a minimum, this table must include the connection ID, source port ID, and destination port ID.
The systemcomposer.importModel(importModelName) API :
Reads stereotype names from the
components table and loads the profiles
Creates components and attaches ports
Creates connections using the connection map
Sets interfaces on ports
Links elements to specified requirements
Saves referenced models
Saves the architecture model
% Instantiate adapter class to read from Excel. modelName = 'simpleUAVArchitecture'; % importModelFromExcel function reads the Excel file and creates the MATLAB tables. importAdapter = ImportModelFromExcel('SmallUAVModel.xls','Components', ... 'Ports','Connections','PortInterfaces','RequirementLinks'); importAdapter.readTableFromExcel();
model = systemcomposer.importModel(modelName,importAdapter.Components, ... importAdapter.Ports,importAdapter.Connections,importAdapter.Interfaces, ... importAdapter.RequirementLinks); % Auto-arrange blocks in the generated model Simulink.BlockDiagram.arrangeSystem(modelName);
You can export an architecture to MATLAB tables and then convert to an external file
exportedSet = systemcomposer.exportModel(modelName); % The output of the function is a structure that contains the component table, port table, % connection table, the interface table, and the requirement links table. % Save the above structure to Excel file. SaveToExcel('ExportedUAVModel',exportedSet);