- Receive your input data signals.
- Unpack the signals using Demux or Bus Selector blocks.
- Feed these signals into the MATLAB Function block that updates the struct fields accordingly.
- Output the updated struct and feed it into your subsystem mask or parameter tuning mechanism.
Use values from UDP receive block to change mask parameter or alter workspace variables
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Antimo
el 25 de Jun. de 2025
Respondida: Shishir Reddy
el 27 de Jun. de 2025
Good evening! I have a complex model that initializes by passing a struct S1 to the mask of a subsystem.
This struct S1 holds the initial values for all the constant blocks within the subsystems. During runtime, I need to modify some values in this S1 struct, which is a tunable parameter. The desired workflow is as follows:
Data is received -> the data is unpacked -> each signal updates a field in S1.
What solutions can I implement using the blocks available in the toolboxes I have?
0 comentarios
Respuesta aceptada
Shishir Reddy
el 27 de Jun. de 2025
Hi @Antimo
Kindly refer to the following steps to achieve parameter tuning at runtime in Simulink -
1.Parameter Struct Initialization: Pass your struct 'S1' to the subsystem mask as a tunable parameter. This allows the subsystem to use the struct values to initialize constant blocks.
2. Updating the Struct Fields at Runtime: Use a MATLAB Function block to receive unpacked signals as inputs, modify the corresponding fields in S1, and output the updated struct. This block allows you to manipulate struct fields programmatically during runtime.
function S1_updated = updateStructSignals(S1, signal1, signal2)
%codegen
S1.field1 = signal1;
S1.field2 = signal2;
S1_updated = S1;
end
3. Workflow:
For more information regarding 'MATLAB Function' block in simulink, kindly refer the following documentation - https://www.mathworks.com/help/simulink/slref/matlabfunction.html
I hope this helps.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!