MATLAB: How to load Simulink objects into MATLAB on another machine

extractsimulink

I have saved signal logging data generated by Simulink into a .MAT file. I would like to load this data into MATLAB on another machine which does not have Simulink installed, however, the data is imported as a single cell instead of the structure that I expected. In addition, I receive the following message:
"Warning: Variable 'variablename' originally saved as a Simulink.ModelDataLogs cannot be instantiated as an object and will be read in as a cell."

Best Answer

In order to read the data generated by Simulink on a machine that has a copy of MATLAB which does not have Simulink installed, you can convert the Simulink.ModelDataLogs object into a standard MATLAB structure. The GET command can be used to extract the properties or fields of the Simulink.ModelDataLogs object. The attached test.mat file contains some sample signal logging data. The following example illustrates how to save this data into a structure that can be imported into MATLAB.
clear
load test.mat
a = get(logsout);
f = fields(a);
b.Name = a.Name;
b.BlockPath = a.BlockPath;
for i = 3:numel(f)
newfieldname = f{i}(isstrprop(f{i}, 'alphanum')); %remove characters that are invalid in a fieldname
b.(newfieldname) = get(a.(f{i}));
b.(newfieldname).TimeInfo = get(b.(newfieldname).TimeInfo);
end