- The "For Each" block can output the value of the for each iterator. You can wire it to the place you wanted or observe it at the output of the "For Each" block.
- Add a masked parameter to the "For Each Subsystem". Specify the value of the parameter as [1:N] outside of the "For Each Subsystem". Through parameter patition, you will get the "index" of the "for each" block anywhere inside the "For Each Subsystem" without the need of wiring.
How to get 'gcb' information including a 'for each' index
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi All
I have a function that has a property 'sParInstanceName'. This variable is updated on starting with the callback function 'InitFcn'.
set_param(gcb,"sParInstanceName",gcb);
This works 'almost' fine. It gets me the path within the model, but it doesn't show the 'index' of the 'for each' block. I don't want to copy the 'index' down via an inport, as this function is the lowest function in about 4 levels of subsystems. It would mean I have to add this additional inport to ALL blocks. Is there maybe an other way of adding this 'index' to the information gathered from the 'gcb' command?
I would like to have this feature, as I have 46 instances of this function and this would help in my debugging. Thanks for any replies.
Ludo
0 comentarios
Respuestas (1)
Fangjun Jiang
el 4 de En. de 2024
Editada: Fangjun Jiang
el 4 de En. de 2024
The "InitFcn" runs only once before each simulation. Whatever info got set to the block is static. The "index" of the "for each" block is dynamic. So I don't think you can achieve what you want by setting dynamic info to a static field of a block property or parameter.
If you have to know the "index" of the "for each" block for debugging purpose, there are two ways.
2 comentarios
Fangjun Jiang
el 15 de En. de 2024
Use approach 2 then. Define and partition a parameter. This parameter can be used anywhere inside the for-each subsystem.
Ver también
Categorías
Más información sobre Programmatic Model Editing 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!