Where is "Go to definition" Feature! Navigating objects and methods in MATLAB

28 views (last 30 days)
I have a lot of classes and methods in my project. I've been putting up with the lack of "Go to definition" feature/aka Ctrl+click (along with Alt+left and right to navigate back and forth) only because of MATLAB'S speed (It is blazing fast! Even C++ Armadillo can't catch up). However, I'm not sure if it is feasible for long-term algorithm development (+ object-oriented code) without this feature.
Other IDEs like PyCharm, CLion, and Visual Studios all have this, and it makes developing/refactoring code so much more efficient and easier.
Has anyone found a solution for this? Or, is this the price I have to pay to use MATLAB? I've found out about VS Code MATLAB plugin and it is quite great with the colors and all but the "Go to definition" doesn't work for methods.
I've tested the same algorithm with Python+Numpy and it is about 2x slower but it is free and the IDE really accelerates the code development time beyond 2x, so maybe, I'll just have to move to Python?

Answers (1)

Image Analyst
Image Analyst on 29 Aug 2022
Edited: Image Analyst on 29 Aug 2022
  1. Right click in the function you want to go to the source code of. Then select "Open thatFunctionName".
  2. Or click in the function name and type control-D.
Not sure about with the VS Code plugin because I don't use that.
  8 Comments
Image Analyst
Image Analyst on 29 Aug 2022
If I do this:
e = Excel_utils;
b = e.ActivateSheet
and click somewhere in ActivateSheet, then it won't work UNTIL I run the program. Reason being that the "e" variable does not exist if I'm just not running the program and am just editing. There is no "e" variable yet (while editing) so of course the ActivateSheet method of that (non-existent) class does not either.
Now, if I do
e = Excel_utils.ActivateSheet;
then that works because Excel_utils is not an instance/object - it's a static class.
However if I run the code and put a breakpoint on the b= line of code then I CAN go into the ActivateSheet source code because by that time, the e object has been created, and this ActivateSheet method will be a part of that object.
Kaung
Kaung on 29 Aug 2022
I see... Thanks for the explanation. I tried what you mentioned (running once first before) and it is still not working.
I believe it is because I'm instantiating with the parenthesis someClass1 = someClass(1,1) because it is not a static class like Excel_utils. The objects we're modeling need to have both state and behavior.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!