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

1 view (last 30 days)
% --- 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

Answers (1)

Ameer Hamza
Ameer Hamza on 6 Jun 2020
Try this
set(handles.raiz,'String',num2str(r));
Convert the numeric value to character value.
  2 Comments
Image Analyst
Image Analyst on 6 Jun 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

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!