Error code in gui

6 Ansichten (letzte 30 Tage)
sha
sha am 29 Okt. 2012
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!

Akzeptierte Antwort

Pedro Villena
Pedro Villena am 29 Okt. 2012
Bearbeitet: Pedro Villena am 8 Nov. 2012
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 Kommentar
Walter Roberson
Walter Roberson am 29 Okt. 2012
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by