In MATLAB, the behavior of resolving names when selecting and opening code is indeed governed by its internal name resolution rules. When you have a property and a class (or function) with the same name, MATLAB defaults to opening the property first. Unfortunately, there is no direct, documented way to change this behavior. However, you can consider the following workarounds:
1. Manual Navigation:
- Instead of relying on the "open" command, manually navigate to the desired class or function in the Current Folder window or use the "Go To" feature in the editor to find the class or function definition.
2. Use Fully Qualified Names:
- When writing code, use fully qualified names to distinguish between the property and the class. This can help clarify your intentions and make it easier to navigate manually.
3. Refactor Code:
- If feasible, consider renaming either the property or the class to avoid name conflicts. This can improve code readability and reduce confusion.
4. Create Helper Scripts:
- Write a small script or function that uses which or similar commands to programmatically determine and open the desired class or function file.
Below is a sample MATLAB script that helps to open a specific class or function:
function openClassOrFunction(name, type)
error('Please specify both the name and type (class/function).');
filePath = which(name, '-all');
error('Type must be either "class" or "function".');
error('The specified %s "%s" could not be found.', type, name);
Please find attached the documentation of functions used for reference:
I hope this helps in resolving the issue.