Wednesday, 7 November 2018

MATLAB - Set text in TextBox on PushButton action

%Example - 1
% --- Executes on button press in pushbutton1
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Set text  in textbox1 on pushbutton1 action


set(handles.textbox1,'string','New Text here on clicking pushbutton1');



%Example - 2
% --- Executes on button press in pushbutton1
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Set text  in textbox1 on pushbutton1 action - Convert number to string


intNum=5999; 
% var intNum need to be converted to  a string
strintNum = num2str(intNum);
set(handles.textbox1,'string',strintNum);
 
 
 


No comments:

Post a Comment

MATLAB - Clear all Axes on button press in Pushbutton

% --- Executes on button press in pushbutton function pushbutton_Callback(hObject, eventdata, handles) % hObject    handle to pushbutton (s...