Invalid handle object, Please help!
古いコメントを表示
I am programming a function for a edit text box that allows the user to input a min and max for the axes in a graph:
function edit1_Callback(hObject, eventdata, handles)
%Input X-Min value for axes1
user_entry = str2double(get(hObject, 'String'));
if isnan(user_entry)
errordlg('You must enter a numeric value.')
uicontrol(hObject)
return
end
set(handles.axes1, 'XLim', [user_entry Inf]);
guidata(hObject, handles);
However, I get a error message saying "Invalid handle object." at the set line. I suspect it has to do with the 'handles.axes1', but I'm not sure how to fix it. Can anyone help? Thanks in advance
3 件のコメント
Melvin
2013 年 6 月 6 日
Walter Roberson
2013 年 6 月 6 日
You have not given us reason to expect that handles.axes1 was ever created, let alone that reason to think it should still be valid. We are going to need to see more of the code, including the code for every routine you invoke between start-up and the time you run into that problem in the callback.
Melvin
2013 年 6 月 6 日
回答 (1 件)
Walter Roberson
2013 年 6 月 6 日
0 投票
It appears then that handles.axes1 was initialized, but that the axes was destroyed before you use it.
The probable reason for that is as described at the beginning of http://www.mathworks.co.uk/matlabcentral/answers/78221-problem-with-axes-handle#answer_87936
7 件のコメント
Melvin
2013 年 6 月 6 日
Walter Roberson
2013 年 6 月 6 日
Which MATLAB version are you using?
At the MATLAB command line, give the command
help hold
Does the output include the line
hold(AX,...) applies the command to the Axes object AX.
??
If you give the command at the command line
dbstop if error
and then run, then when the program stops to report the error, at the K> prompt, give the command
dbup
until it shows that you are at your hold() call. At that point, please show the output of
ishandle(handles.axes1)
Melvin
2013 年 6 月 6 日
Walter Roberson
2013 年 6 月 6 日
I believe hold() accepted axes handles back then as well. But ishandle() showing 0 is a problem.
If you put a breakpoint in at the set(), run up to there and then test
ishandle(handles.axes1)
and also show the numeric value of handles.axes1
I suspect that we are going to need to see more code, of every routine involved in the set-up and every routine you invoke up until the edit1 callback is called.
Melvin
2013 年 6 月 6 日
Walter Roberson
2013 年 6 月 6 日
Note that
handles.axes1 = axes('XScale', 'linear');
creates a new axis, rather than changing the current handles.axes1 to be linear.
Melvin
2013 年 6 月 7 日
カテゴリ
ヘルプ センター および File Exchange で App Building についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!