Hi, I have made a gui using GUIDE. When i call a function that is changing the path of matlab current directory. I get the following warning:
Warning: Function plot has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
> In gui>browse_Callback at 313 In gui_mainfcn at 96 In gui at 42 In @(hObject,eventdata)gui('browse_Callback',hObject,eventdata,guidata(hObject))
There appears also a warning upon startup of Matlab:
Warning: Function plot has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. I have already tried this http://www.mathworks.com/matlabcentral/answers/215315-warnings-and-error-messages-after-launching-matlab-r2015a-for-the-first-time Thanks alot

댓글 수: 1

Stephen23
Stephen23 2016년 1월 26일
Why bother changing directory anyway? It is easier to pass an absolute/relative path. Doing so also avoids a the pain of debugging while changing directories.

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

 채택된 답변

Image Analyst
Image Analyst 2016년 1월 25일

1 개 추천

This is most likely the problem:
path = strcat(path_choice);
path is a very important built-in global variable for MATLAB and you just destroyed it. Pick another name, like "folder" instead of "path". "folder" is okay to use.
Don't use cd() anyway - see the FAQ. Just construct a full filename with sprintf() and fullfile() whenever you need it and leave the current folder alone or you could have trouble later when you try to call functions that are no longer in the current folder.

댓글 수: 12

Student new
Student new 2016년 1월 25일
Still it gives the same error after changing path to folder.
Image Analyst
Image Analyst 2016년 1월 25일
Call them. I had the same problem where it complained about format() but I had no such function. I forgot how they fixed it, but it wasn't because I had a function called that. However it only complained when I tried to compile the program into a standalone executable, not when I just tried to run it from the MATLAB development environment.
Student new
Student new 2016년 1월 25일
Call them?
Image Analyst
Image Analyst 2016년 1월 26일
Sorry, if you're a student, you probably don't have tech support. Ask a professor to call for you.
Walter Roberson
Walter Roberson 2016년 1월 26일
Please show the current version of the code.
And tell us what this says:
which -all plot
Student new
Student new 2016년 1월 26일
편집: Walter Roberson 2016년 1월 26일
Only I get the warning discussed in question when the following function browse & set the path
function browse_Callback(hObject, eventdata, handles)
directory_choice = uigetdir('Select a directory');
cd(directory_choice);
selected= strcat(directory_choice);
set(handles.edit3, 'String', selected);
Walter Roberson
Walter Roberson 2016년 1월 26일
Inside the directory you selected, you have a file named plot.m
Note: strcat(directory_choice) is the same as directory_choice as uigetdir() always returns a string except when the user cancels. (If the user cancels then uigetdir returns numeric 0, and you would have failed on cd(0) so you would not have reached that point in the code.)
Student new
Student new 2016년 1월 26일
편집: Student new 2016년 1월 26일
There is no file named plot.m in the directory i am working in.
Image Analyst
Image Analyst 2016년 1월 26일
편집: Image Analyst 2016년 1월 26일
Can you just do what I asked, anyway?
And tell us what this says:
which -all plot
Do it from your code since it appears that plot() is a function defined inside your main GUIDE m-file, not in a separate m-file.
Of hold down control-shift-F and type plot( into the search field and see what lines it brings up.
Student new
Student new 2016년 1월 26일
Thanks alot Image Analyst... The pathtool was not setting my current working directory properly.
Image Analyst
Image Analyst 2016년 1월 26일
What do you mean by the pathtool?
Do you mean the "Set Path" button on the Home tab of the tool ribbon?
Or do you mean the browsing functionality built into the "Current Folder" panel where you can double-click on the folder to make it the current folder?

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

추가 답변 (1개)

jgg
jgg 2016년 1월 25일

0 개 추천

You've created a function named plot which has the same name as another function already in Matlab.
To fix this, simply rename your plot function something like plot_v and save it in a file with the updated name.

댓글 수: 1

I have not created a function named plot. The following is the function which gives the error when called in Gui.
function browse_Callback(hObject, eventdata, handles)
path_choice = uigetdir('Select a directory');
cd(path_choice);
path= strcat(path_choice);
set(handles.edit3, 'String', path);

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2016년 1월 25일

댓글:

2016년 1월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by