从数据字典导出m文件
打开数据字典,选择Design Data分区,Export to File,可将数据字典导出成m、mat文件
如果用脚本自动实现,涉及的主要功能函数:
- Simulink.data.dictionary.open
打开sldd - getSection
获取数据字典中的Design Data 分区 - exportToFile
将sldd导出成.m或.mat
这里我们先默认导出到MyDictDesignData.m文件,代码示例:
DefaultFile = 'MyDictDesignData.m';
% select .sldd file
[DDFile,~,~] = uigetfile('*.sldd','Select sldd file');
if DDFile == 0
return;
end
% open .sldd file
MyDictObj = Simulink.data.dictionary.open(DDFile);
% export data dictionary entries to mat or matlab file
DataSectObj = getSection(MyDictObj,'Design Data');
% export the entries from the Design Data section of sldd to a MATLAB file in current working folder.
exportToFile(DataSectObj,DefaultFile);
解析m文件录入EXCEL
我们先打开生成的MyDictDesignData.m看下格式
% -------------------------------------------------------------------
% Generated by MATLAB on 26-Feb-2020 11:39:18
% MATLAB version: 9.1.0.441655 (R2016b)
% -------------------------------------------------------------------
A = Simulink.Signal;
A.CoderInfo.StorageClass = 'ExportedGlobal';
A.CoderInfo.Alias = '';
A.CoderInfo.Alignment = -1;
A.Description = 'Global variable';
A.DataType = 'uint8';
A.Min = 0;
A.Max = 255;
A.DocUnits = '';
A.Dimensions = 1;
A.DimensionsMode = 'auto';
A.Complexity = 'real';
A.SampleTime = -1;
A.InitialValue = '0';
MyDictDesignD