Error code in gui

6 visualizaciones (últimos 30 días)
sha
sha el 29 de Oct. de 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!

Respuesta aceptada

Pedro Villena
Pedro Villena el 29 de Oct. de 2012
Editada: Pedro Villena el 8 de Nov. de 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 comentario
Walter Roberson
Walter Roberson el 29 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by