Error code in gui

조회 수: 5 (최근 30일)
sha
sha 2012년 10월 29일
Hi, i wanted to calculate between 3 textbox. and i have created this code. However, i have some error. and i cant figure out.
Code:
----------------------------------------
p = str2num(get (handles.load, ' String'));
d = str2num(get (handles.diameter, ' String'));
n = str2num(get (handles.fringe, ' String'));
f = ( (8 * p ) / (pi * d * n) );
set(handles.result, 'String', f);
------------------------------------------
The error:
------------------------------------------
??? Error using ==> get There is no ' String' property in the 'uicontrol' class.
Error in ==> New>calculationPushbutton_Callback at 387 p = str2num(get (handles.load, ' String'));
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> New at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)New('calculationPushbutton_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
---------------------------------------
PLEASE HELP ME!!!
Thanks!

채택된 답변

Pedro Villena
Pedro Villena 2012년 10월 29일
편집: Pedro Villena 2012년 11월 8일
The sintaxis is good, but you left a space in the beginning of ' String'. Just erase the space blank that is before String
Fail code:
p = str2num(get (handles.load, ' String'));
d = str2num(get (handles.diameter, ' String'));
n = str2num(get (handles.fringe, ' String'));
Correct code:
p = str2num(get (handles.load, 'String'));
d = str2num(get (handles.diameter, 'String'));
n = str2num(get (handles.fringe, 'String'));
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 10월 29일
Good catch, I didn't notice that.
The String property for a pushbutton is the label that will be used for the button, and would not usually be a numeric value. You need to be careful, though, as str2num() will take in a string and eval() it to try to get a number.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by