Can I debug Matlab class objects in Simulink Matlab Function block?

It appears that Matlab objects embedded as persistent variables in a Matlab Function block cannot be viewed in a debugging session.
For instance, with an object a with member x, when stopped in a debug session, if I type the name of the object or reference a member, I get:
debug>> a
a =
Variables of class type cannot be displayed.
debug>> a.x
Attempt to reference field of non-structure array.|
I am using R2012b. Any ways to enable this debugging capability? It's extremely important for effectively using these in models.

6 commentaires

You can define things extrinsically in the MATLAB function. This will allow you to utilize the MATLAB interpreter instead of having MATLAB generate code for the block.
However, if you need to deploy the MATLAB function, it will require code generation.
Thanks - that's a good idea. I'm not sure how it will play out for me though - I debugged a particular object in Matlab, then pumped the same input Matlab data through a Simulink encapsulation and it bombs. Going "extrinsic" may not solve my problem. Wish we wouldn't keep getting these partial implementations of new capabilities, with the rest arriving many versions later.
The big issue here sounds like code generation. Whenever you use the MATLAB function it will generate code unless you tell it not to (extrinsic). You could write your entire function as an m-file, then call that m-file extrinsically in the MATLAB function block. There may be some data type issues you will need to resolve as Simulink is stricter on datatype usage.
Thanks Ryan. I have run the function as extrinsic and then it runs fine from Simulink. I need to eventually get these algorithms through Matlab/Simulink/Embedded Coders to deploy them. I spent a good deal of time tweaking the objects to get them through the code generation process. Without being able to see what is happening in my object during run-time, I can't isolate the problem(s). Unfortunately to get to code deployment I will have to rework these into a non-object Matlab or Simulink form or into C++ and S-function.
Aaron: If debug capability for MATLAB class objects with the MATLAB Function block is important to you, I would encourage you to submit an enhancement request via MathWorks Technical Support. Thanks!
Is this feature on a road map? I'm debugging a large model on 2020a and can not see into any of my MATLAB objects while debugging my Simulink models. Thanks!

Connectez-vous pour commenter.

Réponses (0)

Produits

Question posée :

le 21 Déc 2012

Commenté :

le 5 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by