sl_customization - Update Lookup Table Data (Non-Standard Format)

1 次查看(过去 30 天)
-In the link below, section "Propagate Nonstandard Format Lookup Table Data", an example is given on how to propogate non-standard lookup table data to the workspace. Is there a way to propogate this to a data dictonary variable instead? The data that is propogated is just the table data and not the breakpoint data, can the breakpoints be accessed as well?
If this isn't possible is there a way to access the table editor data programmatically?

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2020-1-9
As far as propagating modified data back to its source variable, it doesn't matter whether the source variable is in the base workspace or a SLDD. Try it and it works when the variable is in a SLDD.
  3 个评论
Fangjun Jiang
Fangjun Jiang 2020-1-9
Migrate your model with base workspace data to using a SLDD. All the changes will be reflected to the SLDD. Use a 2d table example so you will be able to view and change the table data and propagate it back to SLDD.
William Curry
William Curry 2020-1-9
-My Model is already using a data dictonary. The code I'm using below. You can see in the function "myConvertTableFcn" I had to access the SLDD in order to get anything to be saved to the SLDD. I believe the issue is in tableWorkSpaceVarName class below (Next to the ISSUE HERE? comment). Is there a different class call for the data dictonary?
function sl_customization(cm)
cm.LookupTableEditorCustomizer.getTableConvertToCustomInfoFcnHandle{end+1} = ...
@myGetTableConvertInfoFcn;
end
function blkInfo = myGetTableConvertInfoFcn(blk,tableStr)
global currentSystem block
block = blk;
currentSystem = gcs;
nameOfTable = lower(get_param(block,'Name'));
blkInfo.allowTableConvertLocal = true;
blkInfo.tableWorkSpaceVarName = nameOfTable; %%%%%%%%%%%%%%%%%ISSUE HERE????
blkInfo.tableConvertFcnHandle = @myConvertTableFcn;
end
% Converts 3-dimensional lookup table from Simulink format to
% nonstandard format used in workspace variable
function cMap = myConvertTableFcn(data)
global currentSystem block nameOfTable
nameOfTable = lower(get_param(block,'Name'));
tableDimensions = get_param(block,'NumberOfTableDimensions');
dataDictonary = Simulink.data.dictionary.open(get_param(currentSystem,'DataDictionary'));
dDataSectObj = getSection(dataDictonary,'Design Data');
tableEntry = getEntry(dDataSectObj,nameOfTable);
oldTableVal = getValue(tableEntry);
if(strcmp(tableDimensions,'1'))%if this table has 1 dimension set y val
oldTableVal.Value.y = data;
setValue(tableEntry,oldTableVal);
elseif(strcmp(tableDimensions,'2'))%if this table has 2 dimension set z val
oldTableVal.Value.z = data;
setValue(tableEntry,oldTableVal);
end
cMap = data;
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Nonlinearity 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by