How to get information on a Simulink.Signal data store?
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Hadi Zyien
 el 11 de Dic. de 2018
  
    
    
    
    
    Editada: Monika Jaskolka
      
 el 12 de Dic. de 2018
            If I create a data store in the base workspace like so:
DataStore = Simulink.Signal;
DataStore.Description = 'Stores data for a variable.';
DataStore.DataType = 'double';
DataStore.Complexity = 'real';
DataStore.Dimensions = 1;
DataStore.SamplingMode='Sample based';
DataStore.SampleTime = 0.1;
how can I later get this data via the Command Window, specifically the DataType? I can access it by double-clicking the workspace variable (shown below), but I need to get this data programmatically for a script.

0 comentarios
Respuesta aceptada
  Monika Jaskolka
      
 el 12 de Dic. de 2018
        
      Editada: Monika Jaskolka
      
 el 12 de Dic. de 2018
  
      A function will have its own workspace, so you will have to get the Simulink.Signal object from the base workspace first:
% Get all Simulink.Signal objects
workspaceData = evalin('base', 'whos');
idx = ismember({workspaceData.class}, 'Simulink.Signal');
allDs = workspaceData(idx);
% Find the object that is named 'DataStore'
match = strcmp({allDs.name}, 'DataStore');
ds = allDs(match);
% Get the Signal object
ds = evalin('base', ds.name);
% Get the type
type = ds.DataType;
type = get(ds, 'DataType'); % Alternative command
0 comentarios
Más respuestas (1)
  Fangjun Jiang
      
      
 el 12 de Dic. de 2018
        Just like you did in the script, as long as you know the Simulink.Signal object name.
To get the data type: DataStore.DataType or get(DataStore,'DataType')
To set the data type: DataStore.DataType='single' or set(DataStore,'DataType','single')
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!