Clear Filters
Clear Filters

How do I solve this error in Parameter Setting for 2-D Lookup Table Block in Simulink?

13 views (last 30 days)
I'm trying to create a surrogate model for vehicle dynamics in Simulink, but I'm encountering an error when setting parameters for the 2-D Lookup Table block. I would greatly appreciate any advice.
When executing the following code, this error occurs.
set_param([modelName '/SurrogateModel'], ...
'RowIndex', mat2str(throttleBreakpoints), ...
'ColumnIndex', mat2str(brakeBreakpoints), ...
'Table', mat2str(speedData));
Error message:
There is no parameter named 'RowIndex' in the Lookup_n-D block
I can't figure out how I can solve this kind of error.
I was wondering if you could give me a solution.
How should I modify the code?
Here is my matlab script to create the surrogate model.
Full Script
% Create a surrogate model for vehicle longitudinal dynamics
% Set model name
modelName = 'VehicleLongitudinalSurrogate';
% Create new Simulink model
new_system(modelName);
open_system(modelName);
% Input: Throttle position (0-100%)
add_block('simulink/Sources/In1', [modelName '/Throttle']);
set_param([modelName '/Throttle'], 'Position', [100, 100, 130, 130]);
% Input: Brake pressure (0-100%)
add_block('simulink/Sources/In1', [modelName '/Brake']);
set_param([modelName '/Brake'], 'Position', [100, 200, 130, 230]);
% Surrogate model (Lookup table)
add_block('simulink/Lookup Tables/2-D Lookup Table', [modelName '/SurrogateModel']);
set_param([modelName '/SurrogateModel'], 'Position', [250, 140, 350, 190]);
% Output: Vehicle speed (km/h)
add_block('simulink/Sinks/Out1', [modelName '/Speed']);
set_param([modelName '/Speed'], 'Position', [450, 160, 480, 190]);
% Connect blocks
add_line(modelName, 'Throttle/1', 'SurrogateModel/1', 'autorouting', 'on');
add_line(modelName, 'Brake/1', 'SurrogateModel/2', 'autorouting', 'on');
add_line(modelName, 'SurrogateModel/1', 'Speed/1', 'autorouting', 'on');
% Set lookup table parameters (simplified data)
throttleBreakpoints = 0:20:100;
brakeBreakpoints = 0:20:100;
speedData = [
120, 100, 80, 60, 40, 20;
100, 80, 60, 40, 20, 0;
80, 60, 40, 20, 0, 0;
60, 40, 20, 0, 0, 0;
40, 20, 0, 0, 0, 0;
20, 0, 0, 0, 0, 0
];
% Set parameters (this is where the error occurs)
set_param([modelName '/SurrogateModel'], ...
'RowIndex', mat2str(throttleBreakpoints), ...
'ColumnIndex', mat2str(brakeBreakpoints), ...
'Table', mat2str(speedData));
% Save and close the model
save_system(modelName, [modelName '.slx']);
close_system(modelName);
disp('Vehicle longitudinal dynamics surrogate model has been created and saved.');
Best,

Accepted Answer

Paul
Paul on 25 Jul 2024 at 3:07
% Create a surrogate model for vehicle longitudinal dynamics
% Set model name
modelName = 'VehicleLongitudinalSurrogate';
% Create new Simulink model
new_system(modelName);
open_system(modelName);
% Input: Throttle position (0-100%)
add_block('simulink/Sources/In1', [modelName '/Throttle']);
set_param([modelName '/Throttle'], 'Position', [100, 100, 130, 130]);
% Input: Brake pressure (0-100%)
add_block('simulink/Sources/In1', [modelName '/Brake']);
set_param([modelName '/Brake'], 'Position', [100, 200, 130, 230]);
% Surrogate model (Lookup table)
add_block('simulink/Lookup Tables/2-D Lookup Table', [modelName '/SurrogateModel']);
set_param([modelName '/SurrogateModel'], 'Position', [250, 140, 350, 190]);
% Output: Vehicle speed (km/h)
add_block('simulink/Sinks/Out1', [modelName '/Speed']);
set_param([modelName '/Speed'], 'Position', [450, 160, 480, 190]);
% Connect blocks
add_line(modelName, 'Throttle/1', 'SurrogateModel/1', 'autorouting', 'on');
add_line(modelName, 'Brake/1', 'SurrogateModel/2', 'autorouting', 'on');
add_line(modelName, 'SurrogateModel/1', 'Speed/1', 'autorouting', 'on');
% Set lookup table parameters (simplified data)
throttleBreakpoints = 0:20:100;
brakeBreakpoints = 0:20:100;
speedData = [
120, 100, 80, 60, 40, 20;
100, 80, 60, 40, 20, 0;
80, 60, 40, 20, 0, 0;
60, 40, 20, 0, 0, 0;
40, 20, 0, 0, 0, 0;
20, 0, 0, 0, 0, 0
];
The block parameters in question are defined at Lookup Table Block Parameters
% Set parameters (this is where the error occurs)
%set_param([modelName '/SurrogateModel'], ...
% 'RowIndex', mat2str(throttleBreakpoints), ...
% 'ColumnIndex', mat2str(brakeBreakpoints), ...
% 'Table', mat2str(speedData));
set_param([modelName '/SurrogateModel'], ...
'BreakPointsForDimension1', mat2str(throttleBreakpoints), ...
'BreakPointsForDimension2', mat2str(brakeBreakpoints), ...
'Table', mat2str(speedData));
disp('Model created')
Model created
% Save and close the model
%save_system(modelName, [modelName '.slx']);
%close_system(modelName);
%disp('Vehicle longitudinal dynamics surrogate model has been created and saved.');

More Answers (1)

Image Analyst
Image Analyst on 24 Jul 2024 at 16:51
There is no rowIndex or columnIndex for set_param. Why do you think there is?
  1 Comment
翼
on 25 Jul 2024 at 2:06
Edited: on 25 Jul 2024 at 2:07
Thank you,
I see...but,
In case of my script code above.
After I set lookup table parameters (simplified data), I can't figure out how I should set parameters...
I'd like to know how I should modify.

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!