How to read the n-d lookup table breakpoint names including Table Data name?

4 次查看(过去 30 天)
Hello,
For one of my automation scripts, I need to extract all the lookup table variable names (I.e., Table Data name, Breakpoint 1, Breakpoint 2,...etc) using MATLAB command.
I can extract the Table data Name only by using below code:
Lkup_Nme_ = find_system(path,'blockType','Lookup_n-D');
So, I am looking the solution in such a way, so that I can get the names of Table data, Breakpoints 1, Breakpoints 2. I.e. abc_Pbar_Zz, abc_Pbar_Xx and abc_A_Yy respectively.

回答(1 个)

Lokesh
Lokesh 2024-4-26
编辑:Lokesh 2024-4-26
Hi Manish,
I understand that you are looking to extract the lookup table variable names using MATLAB commands. To achieve this, you can utilize the "get_param" command, which allows you to extract the values of block parameters. Here is a sample code snippet for your reference:
mdl = 'name_of_model';
load_system(mdl)
TableDataName = get_param([mdl,'/n-D Lookup Table'],'Table')
Breakpoint1_name = get_param([mdl,'/n-D Lookup Table'],"BreakpointsForDimension1")
Breakpoint2_name = get_param([mdl,'/n-D Lookup Table'],"BreakpointsForDimension2")
Refer to the following documentation for more information on 'get_param':
  2 个评论
Manish singh
Manish singh 2024-4-26
Hi Lokesh,
There are many lookup table used in the model. For above command, it might be only possible if block handle is known. If I select the block and then try with your command, It will work. But my requirement is to get the name/value of all the available lookup table, by just giving the path.
Lokesh
Lokesh 2024-4-26
When there are multiple lookup tables used in the model, you can use 'find_system' to first find all instances of the blocks of interest and then iterate over them to extract the desired parameters.
Refer to this code snippet:
lookupTableBlocks = find_system('model_name', 'BlockType', 'Lookup_n-D');
for i = 1:length(lookupTableBlocks)
% Extract block-specific parameters
TableDataName = get_param(lookupTableBlocks{i},'Table');
Breakpoint1_name = get_param(lookupTableBlocks{i},"BreakpointsForDimension1");
Breakpoint2_name = get_param(lookupTableBlocks{i},"BreakpointsForDimension2");
% Display or store the extracted information
fprintf('Block: %s\n', lookupTableBlocks{i});
fprintf('Table Data Name: %s\n', TableDataName);
fprintf('Breakpoint 1 Name: %s\n', Breakpoint1_name);
fprintf('Breakpoint 2 Name: %s\n', Breakpoint2_name);
% You might want to store these in an array or cell array for later use
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by