Check if a variable or field is used?
Show older comments
This feature probably doesn't exist, but I thought I'd ask. Is there a way to check if a certain variable or field in a structure is called? I'm reading through a very large existing code, and rather than trying to step line by line (which is what I'm currently doing), it would be helpful if there was a way for Matlab to tell me that some variable is called or interacted in some way.
5 Comments
Adam
on 29 Jul 2016
If you literally just want to do a one time check can you not just rename it and run your code and see if it still works?
Moe_2015
on 29 Jul 2016
Moved my answer to comment (was not really an answer): Why can't you just do "ctr + f" or in the editor click on "Find" and type in the certain variable or field you are looking for?
Moe_2015
on 29 Jul 2016
Mark Kim's response to my answer: The code is written in such a way that it calls many other functions (a few dozen) and each function calls many structures, and those structures have function handles inside so the actual function name isn't always used when the function is called since most of the time they're called from the handle name.
Mark Kim
on 1 Aug 2016
@Mark Kim: are the fieldnames dynamically generated, ore are they hardcoded ?
I guess the obvious way to achieve your goal would be to overload the struct class, and add some functionality that displays/stores access information when the fields are accessed. (Assuming that they use some kind of get/set methods).
Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!