Passing a Struct from the workspace to System Block
조회 수: 6 (최근 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!