- Are you trying to run (or execute) the code, or are you trying to modify (or edit) the code?
- When you you say "opening", can you describe how you are opening the file? Are you double-clicking on the file in the "Current Folder" browser? Or clicking the "Open" button on the MATLAB tool strip? Or something else?
opening .m file results in "index exceeds the number of array elements"
60 ビュー (過去 30 日間)
古いコメントを表示
I've yet to use MATLAB (new user) and since installing I've had issues with trying to open .m files from Finder (Mac). When opening .m file I get a dialog box that says "index exceeds the number of array elements. Index must not exceed 0"
3 件のコメント
Walter Roberson
2024 年 7 月 15 日
The most common cause of problems like these, is if you have some third-party function with the same name as a Mathworks-supplied function. For example if you have your own length.m then you can encounter these kind of problems.
Experiment with executing
restoredefaultpath; rehash toolboxcache
savepath
Note this will not work if the extra function is in the default directory.
回答 (1 件)
Steven Lord
2024 年 7 月 15 日
How are you trying to open the file? Are you calling open or edit with the name of the file as inputs? If so, make sure you don't have a variable with the same name as that function and check that you haven't written your own function by that name that's taking precedence over that function included in MATLAB.
which -all open
which -all edit
If you have your own open.m or edit.m that shows up when you execute those commands, rename that file.
3 件のコメント
Steven Lord
2024 年 7 月 15 日
Can you try running those two commands in MATLAB and showing us what they display?
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!