Borrar filtros
Borrar filtros

Debug Simulink MATLAB funciton block inside for each subsystem

26 visualizaciones (últimos 30 días)
Brad
Brad el 3 de Jul. de 2024 a las 13:10
Editada: Fangjun Jiang el 3 de Jul. de 2024 a las 16:21
Is there a way to debug a Simulink MATLAB function block inside a For Each subsystem with the same capabilities that are provided when the function block is not in a for each subsystem?
When troubleshooting a Simulink MATLAB function block inside of a for each subsystem, my breakpoints pause program execution and take me to the breakpoint that activated, but I cannot access any of the variable values via hover or the MATLAB debug console.
The breakpoints seem to activate for every for each iteration (as expected) but I cannot see the values of any variables in the same way that I can when the function block is not in a for each subsystem.
  2 comentarios
Fangjun Jiang
Fangjun Jiang el 3 de Jul. de 2024 a las 14:20
Do you get the correct value if you type the variable name in the Command Window during the debugging mode?
Brad
Brad el 3 de Jul. de 2024 a las 14:59
No. The console responds with a notice that it cannot find the variable specified. The workspace is also empty.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 3 de Jul. de 2024 a las 16:08
Editada: Fangjun Jiang el 3 de Jul. de 2024 a las 16:21
Yes. I can confirm this behavior in R2022b.
When setting the loop number N to be 1, you will see the normal debugging behavior.
When setting the loop number N to be 2, you will see the normal "hover and show value" behavior every second time when the pause happened.
It is true that "The breakpoints seem to activate for every for each iteration (as expected)". But the breakpoints seem to be useless when it is not at the last iteration of the for-each subsystem execution.
The for-each subsystem has some limitations but I didn't find one that is related to this behavior.
There might be a reason for this. Any Mathworkers can provide an insight? Or this could be a shortcoming. Maybe the Mathowrks can improve it to meet this needed debugging behavior.
I tried to find a work-around for this. First, check the option "Show partition index output port" at the ForEach block and feed this signal to the MATLAB Function block so you can use it.
First, the conditional breakpoint did not work due to the same reason. If N is 10 and I set a conditional breakpoint when N==5, trying to observe certain values when iteration is at 6 (due to zero-based index), it gives error because N is not visible for debugging.
The other work-around is to add some code, such as if N==5, disp(SomeVariables), end. This seem to work. So the value is there in the code and it reflects the correct iteration. It is just not visible for debugging.
I hope this helps a little at least.
  1 comentario
Brad
Brad el 3 de Jul. de 2024 a las 16:16
Thanks! I didn't realize that the last iteration had full debug behavior. That's very useful. I haven't pursued the disp strategy yet, but may have to if a MATLAB rep doesn't chime in with a better solution.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by