0

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);
Santron Manibharathi
  • 628
  • 5
  • 12
  • 26

2 Answers2

0

Given the comments it is safe to say that nothing is wrong with this piece of code.

This is not yet a solution, but it seems clear that you are searching in the wrong place.

Two things that you want to check:

  • The state your program is in at the time the function is called, maybe there is something strange going on with the relevant variables.
  • Whether there is a problem with the availability of files that you use as input, if you use a file right after it is updated this may be a cause of problems.
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
0

It worked when i gave the code in pushbutton1_Callback(...) function. Thanks.

Santron Manibharathi
  • 628
  • 5
  • 12
  • 26