Function in MATLAB's path not call-able by another function in MATLAB's path despite both functions being call-able in Command Window

조회 수: 11 (최근 30일)
I have a function, "cmap", that refuses to be called by another function "mproc", though both are in MATLAB's path (I have repeatedly verified that both functions are in folders in MATLAB's path). "mproc" runs fine and can call other functions that are not "cmap", but when it gets to cmap I get one of two errors, copied and commented below:
% 'cmap' is not found in the current folder or on the MATLAB path, but exists in:
% C:\Users\my_name\Documents\MATLAB\Image Processing\Cmap functions
% Change the MATLAB current folder or add its folder to the MATLAB path.
or
% Unrecognized function or variable 'cmap'.
The folder that it's in IS on the MATLAB path, however. Even so, when I click "add its folder to the MATLAB path" anyways, the same error persists when I try to use it again.
This is particularly confusing because I can call "cmap" in the Command Window (since it's in MATLAB's path). I was not having this issue earlier today but suddenly MATLAB just refuses to use "cmap" in "mproc". Am I missing something completely obvious?
Here is a picture of my MATLAB, showing "cmap" in a folder that is on the MATLAB path, mproc is in the "Image stack functions" folder (also in MATLAB's path). I have highlighted the line of code where the program breaks and an error message is displayed below.
  댓글 수: 3
Cris LaPierre
Cris LaPierre 2023년 6월 6일
편집: Cris LaPierre 2023년 6월 6일
You've ruled out the main culprits I would suspect. Does this go away after restarting MATLAB? Is this behavior reproducible on other machines?
Lars Nelson
Lars Nelson 2023년 6월 7일
It did not go away after re-starting MATLAB, no. I don't have another machine to test it on, unfortunately.

댓글을 달려면 로그인하십시오.

채택된 답변

Lars Nelson
Lars Nelson 2023년 6월 7일
이동: Matt J 2023년 6월 7일
I changed the name of the cmap function to createcmap and that seems to have fixed it. Not sure why MATLAB suddenly decided that this function name was not allowed as it had been working half an hour before I encountered the issue.

추가 답변 (2개)

Matt J
Matt J 2023년 6월 6일
So this specific line of code is just refusing to work for seemingly no reason.
Maybe there is some invisible character in that line that is corrupting the call? Try deleting the whole line and retyping it.

Matt J
Matt J 2023년 6월 6일
편집: Matt J 2023년 6월 6일
Possibly mproc or one of its callers has path-altering commands that temporarily remove cmap from the path. To be certain, we would need you to set a breakpoint at line 719 and display the path only after execution pauses there.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by