Undefined function when successfully opening .fig
古いコメントを表示
I am opening a new GUI window when a user clicks a button in an existing window. To do this, in the button callback I issue the command
gui2Handle = open('GuiWindow2.fig');
However, Matlab then prints the error
Undefined function 'GuiWindow2' for input arguments of type 'char'.
which is strange because I'm not giving any arguments at all. It seems like for some people this error results when there's an issue with the path, but when I type
which GuiWindow2.fig
into the command window, I get the correct directory. Additionally, after Matlab prints the error about input arguments of type 'char' a couple of times, it then goes on to open the figure, and so far I haven't found anything about it that doesn't work.
I've tried debugging with "if error" but although it stops as soon as it prints the undefined function error, it doesn't bring me to any line in the code, then if I step through, it might print the error once more and then the figure appears, but the debugger never highlights any lines of code.
Any ideas on why this error is appearing and how to remove it?
回答 (2 件)
Star Strider
2014 年 7 月 24 日
0 投票
3 件のコメント
Forrest
2014 年 7 月 24 日
Star Strider
2014 年 7 月 24 日
Still guessing here, but what happens when you do:
[Q1,Q2,Q3] = fileparts(which('GuiWindow2.fig'));
X = dir([Q1 '\*.fig'])
My guess is that it’s defaulting to the wrong directory. (I tested this code on my system, but with a different filename. It produces the correct results when I run it.)
Forrest
2014 年 7 月 24 日
Geoff Hayes
2014 年 7 月 24 日
The GUI figure files are not meant to be executed. While it will "launch" if you double-click on it, none of the initializations (that the code needs) will occur.
Try adding the following line in your callback
run('GuiWindow2')
This will call the m-file of the GuiWindow2 code and launch the GUI. I have tried this from the Command Window and from the callback of a push button in a simple GUI.
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!