Hello Community,
I get an error when I execute below. Can you please direct to what could go wrong with pathdef and the resolution of this error?
Thank you in advance!
>> Run_Script
Index exceeds matrix dimensions.
Error Run_Script (line 2)
path(pathdef)

回答 (1 件)

Steven Lord
Steven Lord 2023 年 12 月 5 日

1 投票

Does your Run_Script script file define a variable named path on line 1, right before it tries to call the path function on line 2? [I suspect it does.] As long as that variable exists MATLAB cannot call the path function.
Changing the name of that variable would resolve the problem, but a script file trying to reinitialize the MATLAB search path as part of its execution smells kind of bad to me. Why is your script trying to do that?

4 件のコメント

Samy Alkhayat
Samy Alkhayat 2023 年 12 月 6 日
There is no variable defined as "path". Line 1 is just a %% heading.
The first line of code is:
path(pathdef)
Steven Lord
Steven Lord 2023 年 12 月 6 日
Do you have a variable named path in your workspace when you run the script? To check use this command.
which -all path
/MATLAB/toolbox/matlab/general/path.m /MATLAB/toolbox/matlab/codetools/@mtree/mtree.m % mtree method
Samy Alkhayat
Samy Alkhayat 2023 年 12 月 6 日
Yes, here is what it returns:
C:\Software\Mathworks\Matlab_All_Products_2017a\toolbox\matlab\codetools\@mtree\path.m % Shadowed mtree method
C:\Software\Mathworks\Matlab_All_Products_2017a\toolbox\driving\driving\@drivingScenario\path.m % Shadowed drivingScenario method
C:\Software\Mathworks\Matlab_All_Products_2017a\toolbox\matlab\general\path.m % Shadowed
Samy Alkhayat
Samy Alkhayat 2024 年 1 月 11 日
Hello Steven,
Any feedback on the last provided comment?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2017a

タグ

質問済み:

2023 年 12 月 5 日

コメント済み:

2024 年 1 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by