Passing a Struct from the workspace to System Block
5 ビュー (過去 30 日間)
古いコメントを表示
I am trying to access a struct called "inputs" from the MATLAB workspace while running a system block. When I pass it as an argument to the StepImpl function, it creates a new port in the Block. But I need it to consider "inputs" as a parameter which is accessed from the workspace. This can be done easily in the case of a function block using the Ports and Data Manager and setting the scope of the variable as parameter. Does anyone know how it can be done for a system block ? Is there an equivalent Ports and Data Manager, or is there any other way to access structs from the workspace while running the block ? Any help would be greatly appreciated.
0 件のコメント
回答 (1 件)
Oliver Janda
2021 年 1 月 27 日
編集済み: Oliver Janda
2021 年 1 月 27 日
You can add a non-tunable parameter in the appropriate section at the beginning of the class definition, e.g.
properties(Nontunable)
inputs=0;
end
After saving the file and double-clicking on the Matlab System block in the Simulink model, you get a mask where you can specify a base workspace variable for inputs, which can be struct.
1 件のコメント
Anshul Paunikar
2024 年 1 月 18 日
Hello @Oliver Janda, the solution suggested by you worked for me in MATLAB 2019a, however I have to ultimately implement this in MATLAB 2015aSP1, where it throws an error (Invalid setting for the parameter ‘inputs’). Do you know of a way to get the same functionality in 2015a?
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!