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

조회 수: 8 (최근 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