Matlab does not recognizes function

Hi,
I have a test.m file located in directory temp. This file calls functions named test1 (located in test1.m) test2 (located in test2.m). Both test1.m and test2.m are locted in the same directory as test.m
For calling test1.m it is successive call while for test2.m it tells that function doesn't exists.
Setting breakpoint just before test2 call I'm checking in the command prompt whether it is exists by exist test2 and receiving a positive result (2).
But the call is still with fail.
Only when adding following, I can call the function successfully.
if exist('test2')
test2(...)
end
I have some toolbox (wasn't developed by me) for which this happens a lot of times.
I don't wan't to start digigng for all the places where this happens and doing the update.
What could be done to solev it?

7 件のコメント

per isakson
per isakson 2022 年 8 月 18 日
編集済み: per isakson 2022 年 8 月 18 日
I don't fully understand. Your work-around with exist() puzzles me. Two questions
  • Are you positive that the folder temp is on the Matlab search path?
  • What does dir(fullfile(absolute_path_name_of_temp,'test?.*)) return?
michael
michael 2022 年 8 月 18 日
The temp.m is in my current path
dir(fullfile('absolute_path_name_of_temp','test?.*')) returns
test.m
Jan
Jan 2022 年 8 月 18 日
編集済み: Jan 2022 年 8 月 18 日
"But the call is still with fail." - please share the details with the readers. Do you get an error message? If so, post a copy of the complete message.
"Only when adding following, I can call the function successfully. if exist('test2')" - This sounds magic. Whenever magic appears, you can be sure, that the observations are caused by a simple effect, which is overseen yet.
michael
michael 2022 年 8 月 18 日
Undefined command/function 'test2'.
per isakson
per isakson 2022 年 8 月 18 日
The substring, 'test?.*', should have returned test.m, test1.m and test2.m
What does which test return?
Jan
Jan 2022 年 8 月 18 日
test2()
Unrecognized function or variable 'test2'.
If you get the message "Undefined command/function 'test2'" I wonder, which Matlab version you are using.
Please post an exact copy of the complete error message.
michael
michael 2022 年 11 月 15 日
編集済み: michael 2022 年 11 月 15 日
It have took some time as I was busy with other issues.
If I place the file in C:\Temp\ and execute which test, I'm getting the complete file path.
If I place the file in C:\Temp\MyMap\ and execute which test, I'm getting the complete file path and additional comment `%Has no license available`.
Regarding my Matlab version:
>>version
ans=
7.1.0.246 (R14) Service Pack 3

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTesting Frameworks についてさらに検索

製品

リリース

R14SP2

質問済み:

2022 年 8 月 18 日

編集済み:

2022 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by