Passing a Struct from the workspace to System Block
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Oliver Janda
il 27 Gen 2021
Modificato: Oliver Janda
il 27 Gen 2021
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 Commento
Anshul Paunikar
il 18 Gen 2024
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?
Vedere anche
Categorie
Scopri di più su Event Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!