uicontrol Handles Error using set

maxDrag = num2str(round(max(data_to_plot)), '%7.5g');
set(handles.maxDrag, 'String', ['Max Drag: ', maxDrag, ' lbs'])
I receive the following error with my use of set. What is wrong with what I have done?
Error using set
Value must be a handle
Error in test>pushbutton_run_Callback (line 188)
set(handles.maxDrag, 'String', ['Max Drag: ', maxDrag, ' lbs'])
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in test (line 60)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)test('pushbutton_run_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

 採用された回答

Jan
Jan 2013 年 1 月 17 日
編集済み: Jan 2013 年 1 月 17 日

0 投票

The message is clear: handles.maxDrag is not a handle. Then you cannot use it to set properties.
How and where is the field defined? Has the corresponding UI object been deleted already?
Btw.: The error message does not come from the two posted code lines, but from line 188. Perhaps you have edited the M-file but did not save it before running?

3 件のコメント

T
T 2013 年 1 月 17 日
I have edited the second line. I should then write:
maxDrag = handles.maxDrag
Walter Roberson
Walter Roberson 2013 年 1 月 17 日
Not likely. your maxDrag is a string created by num2str(). If you overwrite it with a handle then using it as a string will not work. If you overwrite the handle with a string, then using the handle will not work.
Hint: rename the string variable as maxDragstr so that you do not confuse it with maxDrag as a handle.
T
T 2013 年 1 月 17 日
It works. I think it's because I didn't take the button using guide.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

タグ

質問済み:

T
T
2013 年 1 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by