getOutputNamesImpl

Names of MATLAB System block output ports

Syntax

names = getOutputNamesImpl(obj)

Description

names = getOutputNamesImpl(obj) specifies the names of the output ports from System object™, obj implemented in a MATLAB System block. The size of names matches the number of outputs returned by the getNumOutputs method. If you change a property value that affects the number of outputs, the names of those outputs also change.

Class Information

This method is part of the matlab.System class.

Run-Time Details

getOutputNamesImpl is called by the MATLAB System block.

Method Authoring Tips

You must set Access = protected for this method.

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your getOutputNamesImpl method does not use the object, you can replace this input with ~.

Output Arguments

expand all

Names of the outputs for the specified object, returned as a string array whose length equals the number of outputs.

Examples

expand all

This example shows how to specify the names of ports of a MATLAB System block by adding methods to the underlying System object.

To specify port names for the MATLAB System block, you must add specific methods to the underlying System object. In the System object, add the getInputNamesImpl method to specify the names of two input ports as upper and lower. Additionally, add the getOutputNamesImpl method to specify the output port name as Count.

classdef ExamplePortNames < matlab.System
    
    properties(Nontunable)
        UseOptionalInput (1,1) logical = false;
    end
    
    methods (Access = protected)
        function inputNames = getInputNamesImpl(obj)
            if getNumInputs(obj) > 1
                inputNames = ["upper","lower"];
            else
                inputNames = "upper";
            end
        end
        
        function outputNames = getOutputNamesImpl(~)
            outputNames = "count";
        end
        
        function y = stepImpl(obj,upper,lower)
            if obj.UseOptionalInput == 2
                y = (upper + lower)/2;
            else
                y = upper;
            end
        end
        function num = getNumInputsImpl(obj)
            num = 1;
            if obj.UseOptionalInput
                num = 2;
            end
        end
    end
end

When you include the System object in a MATLAB System block, the ports appears as:

Introduced in R2013b