フィルターのクリア

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

13 ビュー (過去 30 日間)
翼
2024 年 7 月 24 日 16:09
コメント済み: 2024 年 7 月 25 日 9:01
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 日 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.');

その他の回答 (1 件)

Image Analyst
Image Analyst 2024 年 7 月 24 日 16:51
There is no rowIndex or columnIndex for set_param. Why do you think there is?
  1 件のコメント
翼
2024 年 7 月 25 日 2:06
編集済み: 2024 年 7 月 25 日 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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by