Unable to run local function "myparse"
76 views (last 30 days)
Show older comments
I am unable to run a local function "myparse" even though it is already on my path. Anyone has any idea how to solve this?
>> ver
-----------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2668659 (R2023b) Update 9
MATLAB License Number: STUDENT
Operating System: macOS Version: 14.4.1 Build: 23E224
Java Version: Java 1.8.0_392-b08 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------
MATLAB Version 23.2 (R2023b)
Image Processing Toolbox Version 23.2 (R2023b)
M2HTML Toolbox - A Documentation Generator for ... Version 1.4
Parallel Computing Toolbox Version 23.2 (R2023b)
Statistics and Machine Learning Toolbox Version 23.2 (R2023b)
Thank you!
6 Comments
Wai Cheng
on 28 Oct 2024 at 8:29
Edited: Walter Roberson
on 29 Oct 2024 at 4:55
Rahul
on 28 Oct 2024 at 9:03
Edited: Rahul
on 28 Oct 2024 at 9:09
@Wai Cheng, I am unable to reproduce the issue you have provided in MATLAB R2023b. The issue could be encountered if possibly some another function with name 'myparse' could be on MATLAB path, for which you can use the following command:
>> which myparse
If you find another function, you can try removing the undesired function from path manually, and in case you don't find the desired myparse file on path, you can add it using the following command:
>> addpath('path/to/your/desired/myparse.m')
You can try restarting your current MATLAB session.
The best practice here could be to rename the given function, since often MATLAB can check in folders with the same name as the function, which might not be installed.
To find the products, toolboxes and files required by a specific code or file, you can use the following function:
[~, products] = matlab.codetools.requiredFilesAndProducts('myparse.m');
disp(products.Name)
In your case, the products array contains a single element with name 'MATLAB' stating no requirement for 'Medical Imaging Toolbox'.
Answers (4)
Tushar Sharma
on 28 Oct 2024 at 8:25
Hi Wai,
It seems that the function you're trying to use, "myparse," may be causing conflicts in MATLAB. The error you're experiencing typically occurs when a function in your folder has the same name as a toolbox function for which you don't have a license. As a workaround, I suggest renaming your function.
To help identify name conflicts, although only for installed toolboxes, you might find this function useful: https://www.mathworks.com/matlabcentral/fileexchange/27861-uniquefuncnames
埃博拉酱
on 28 Oct 2024 at 10:21
As @Tushar Sharma said, there's a naming conflict. However as @Rahul said, I also can't reproduce this issue. In my experience, MATLAB is generally able to handle the vast majority of naming conflicts correctly. If you don't want to change your function name, you can also try removing your folder from the search path and then adding it again.
It's a good practice for third-party toolboxes to use namespaces to avoid conflicts with official functions.
0 Comments
Rahul
on 28 Oct 2024 at 11:33
Edited: Rahul
on 29 Oct 2024 at 4:39
Hi Wai Cheng,
I understand that you are trying to execute a local function in MATLAB R2023b but getting an error stating “mpyarse requires Medical Imaging Toolbox”.
I am unable to reproduce the issue you have reported, in MATLAB R2023b. The issue could be encountered if possibly some another function with name 'myparse' could be on MATLAB path, for which you can use the following command:
>> which myparse
If you find another function, you can try removing the undesired function from path manually, and in case you don't find the desired myparse file on path, you can add it using the following command:
>> addpath('path/to/your/desired/myparse.m')
You can try restarting your current MATLAB session.
Although, the best practice here could be to rename the given function, since often MATLAB can check for conflicts in folders with the same name as the function, which might not be installed.
Moreover, to find the products, toolboxes and files required by a specific code or file, you can use the following function:
[~, products] = matlab.codetools.requiredFilesAndProducts('myparse.m');
disp(products.Name)
In your case, the products array contains a single element with name 'MATLAB' stating no requirement for 'Medical Imaging Toolbox'.
Hope this helps!
0 Comments
Walter Roberson
on 29 Oct 2024 at 4:57
You could potentially have that problem if your setup function is adding the directory to the end of the MATLAB path instead of at the beginning of the MATLAB path.
See Also
Categories
Find more on Startup and Shutdown 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!