Hey can you please help me with these errors im getting from my GUI

1 visualización (últimos 30 días)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
syms x;
format long
h=get(handles.edit1,'string');
a=str2double(get(handles.edit2,'string'));
b=str2double(get(handles.edit3,'string'));
it=str2double(get(handles.edit4,'string'));
ha=subs(h,a);
hb=subs(h,b);
i=0;
while i~=it
i=i+1;
r=(ha*b-hb*a)/(ha-hb);
fr=subs(h,r);
if fr>it; a=b; b=r;
end
end
if i==it;
set(handles.raiz,'String',r);
end
THESE ARE MY ERRORS
Error using matlab.ui.control.UIControl/set
While setting the 'String' property of UIControl:
String should be char, numeric or cell array datatype.
Error in metodo_de_la_secante>pushbutton1_Callback (line 187)
set(handles.raiz,'String',r);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in metodo_de_la_secante (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)metodo_de_la_secante('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Respuestas (1)

Ameer Hamza
Ameer Hamza el 6 de Jun. de 2020
Try this
set(handles.raiz,'String',num2str(r));
Convert the numeric value to character value.
  2 comentarios
Image Analyst
Image Analyst el 6 de Jun. de 2020
Or, with the preferred, current OOP syntax:
handles.raiz.String = num2str(r); % or sprintf('%.4f', r) if you want more control over its format

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by