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

6 次查看(过去 30 天)
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,

采纳的回答

Paul
Paul 2024-7-25
% 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.');

更多回答(1 个)

Image Analyst
Image Analyst 2024-7-24
There is no rowIndex or columnIndex for set_param. Why do you think there is?
  1 个评论
翼
2024-7-25
编辑: 2024-7-25
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.

请先登录,再进行评论。

类别

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

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by