Problem in savepath in MATLAB 2025B

38 次查看(过去 30 天)
jk_cau
jk_cau 2026-1-15,2:56
移动Angelo Yeo 2026-1-16,5:40
In MATLAB R2025b, I am encountering an unexpected runtime error when executing a very simple script from the MATLAB path.
I add the folder containing my .m file to the MATLAB path using savepath, which allows the script to be executed from any working directory. This workflow has worked correctly in all previous MATLAB versions.
However, in R2025b only, executing the script from outside its folder results in the following exception, even though the script contains only a single line:
filename = 'data_v1.csv';
The error message is:
Caught "std::exception" Exception message is:
Unexpected mxArray type returned from feval. Expected class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > but found string.
There are no calls to feval, no functions, and no toolbox dependencies in the script.
The issue disappears if:
  • All user paths are removed and the script is run from its own directory, or
  • The script is moved out of the MATLAB path and executed locally.
For additional context, the .m file is located in a Dropbox-synchronized folder.
This behavior has never occurred in earlier MATLAB releases and appears to be specific to R2025b. Is this a known regression related to path-based execution, string/char handling, or cloud-synced directories?
  1 个评论
Angelo Yeo
Angelo Yeo 2026-1-15,3:08
I assume something got corrupted in your settings and/or paths. Please follow the initial troubleshooting steps below:
===
1. Reset MATLAB path
Before modifying the search path, it is important to take a backup of your 'pathdef.m' file, which can be located by using the command:
>> which -all pathdef
Before proceeding, ensure that you make a safe copy of the file by copying it to a folder outside of your MATLAB path.
After taking the backup, please execute the following commands in the MATLAB Command Window to restore the default MATLAB/Simulink search path and rehash the toolbox cache:
>> restoredefaultpath
>> rehash toolboxcache
>> sl_refresh_customizations
After this step, please use MATLAB to see if the issue occurs again. If the issue is resolved, then you may want to save the new MATLAB search path by executing the following command:
>> savepath
NOTE: This will remove any custom paths you may have created. The following MATLAB Answers post is an additional resource on how to back them up:
2. Regenerate preferences
Please follow the instructions in this link:
===

请先登录,再进行评论。

采纳的回答

jk_cau
jk_cau 2026-1-15,15:26
移动:Angelo Yeo 2026-1-16,5:40
Angelo,
Thanks for the timely response!
I was able to identify both the cause and the fix.
The issue was due to a folder named MVMD_ver1.m being included in the MATLAB search path. Because the folder name ended with .m, MATLAB appears to have treated it as a function file, which led to the unexpected feval / mxArray error.
After renaming the folder to MVMD_ver1 (removing the .m extension), the error was completely resolved.
I hope this helps others encountering the same issue.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

产品


版本

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by