Main Content

whosImpl

Class: Simulink.io.FileType
Namespace: Simulink.io

Determine contents of MAT-file associated with Simulink.io.FileType object

Since R2020a

Syntax

signals = whosImpl(reader)

Description

signals = whosImpl(reader) returns a structure containing the contents of the MAT-file associated with the Simulink.io.FileType object.

Run-Time Details

whosImpl is called via whos when you run the application. For details, see Create Custom File Type for Import.

Input Arguments

expand all

Reader, specified as a Simulink.io.FileType object.

Output Arguments

expand all

Contents of the MAT-file, returned as an array of structures. This structure has a signal name ['char array'] and an optional signal type of a supported type. For more information on supported types, see Choose a Base Workspace and MAT-File Format.

Examples

expand all

Subclass FileType class and implement the whosImpl method.

classdef MySignalMatFile < Simulink.io.FileType

Implement the static method whosImpl.

methods 
        
        function outOnFile = whosImpl(obj)
            onFile = whos(obj.FileName);
            
            numVars = length(onFile);
            
            outOnFile(1).name = [];
            outOnFile(1).type = [];
            
            for k = 1: length(numVars)
                
                outOnFile(k).name = onFile(k).name;
                
                if strcmpi( onFile(k).class, 'Simulink.SimulationData.Dataset' )
                    outOnFile(k).type = 'Dataset';
                else
                    % Assume Signal(timeseries or timetable)
                    % other acceptable types
                    %  - Bus   : for bus signals
                    %  - Ground: for grounds (empty double)
                    %  - FunctionCall: for single column double data arrays
                    outOnFile(k).type = 'Signal';
                end
                
            end
            
        end
    end

Version History

Introduced in R2020a