I have two textboxes and a button in matlab. Designed the form using GUIDE. I used the following code to copy value from one textbox to another. The code works sometimes and not always. I am not able to find the scenario in which it works and what was wrong with this code.
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
myTextBox1 = findobj('Tag','edit1');
myTextBox2 = findobj('Tag','edit2');
str = get(myTextBox1,'String');
set(myTextBox2,'String',str);