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

1 view (last 30 days)
-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?

Answers (1)

Fangjun Jiang
Fangjun Jiang on 9 Jan 2020
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 Comments
Fangjun Jiang
Fangjun Jiang on 9 Jan 2020
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 on 9 Jan 2020
-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

Sign in to comment.

Categories

Find more on Nonlinearity in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!