How to avoid this warning?

4 ビュー (過去 30 日間)
Student new
Student new 2016 年 1 月 25 日
コメント済み: Image Analyst 2016 年 1 月 26 日
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 日
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 月 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 日
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 件のコメント
Student new
Student new 2016 年 1 月 25 日
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);

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by