GUI Call back Function Error!
1 回表示 (過去 30 日間)
古いコメントを表示
Im trying to create a button that prompts user to select file to load and display.
function loadbutton_Callback(hObject, eventdata, handles)
[datafile datadir] = uigetfile('*.csv');
end
When I run this code on a separate file it works but when I added to my code it gives this error
*Function definitions are not permitted in this context.*
0 件のコメント
採用された回答
Adam
2017 年 3 月 22 日
編集済み: Adam
2017 年 3 月 22 日
What version of Matlab are you using?
I'm guessing you are not in the latest and your main file is a script which does not allow subfunctions.
Just change your script into a function by adding
function myMFilename( )
at the top, obviously replacing myMFilename with whatever is the name of your file.
or move this function into a file of its own somewhere on your path.
0 件のコメント
その他の回答 (1 件)
Yasaman Best
2017 年 3 月 22 日
1 件のコメント
Adam
2017 年 3 月 22 日
It isn't odd, it is for the reason I explained in my answer. Subfunction definitions are not allowed in a script. Apparently they are in the lastest version of Matlab, but I've never tried them. I try to avoid scripts as much as possible!
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!