Problem with guidata in a callback with GUI

Hello! I have a problem with the command 'guidata' in a GUI code. I load a matrix (mat) with a 'Push button' command in the GUI panel and plot it, and it works. Then, I need to cut this matrix by deleting some columns and rows (x vs y axes), and I do this by creating a new function with another 'Push button' command named 'Cut'. The values where I choose to cut the matrix are written in an 'Edit text' command in the GUI panel (I have four edit text commands: first column, last column, first row, last row, named x1,x2,y1,y2, respectively); when I press the Push button 'Cut' , the matrix is cut according to these values, see the code below. The problem is that I can do this only once: if I write again a value in the edit text and press 'Cut', the program doesn't work anymore. The problem should be related to the command guidata (see the line in bold in my code), because if I remove this line from the code the function works, and I can cut the matrix as long as I want. But I need to store the cut matrix as well as the values x1,x2,y1,y2, because I have to recall them in another function, so I need guidata command! How can I modify the callback to solve this problem? Thank you in advance.
Here is the callback function associated to the push button 'Cut'

4 Comments

replace the handles by handles.matcut in the last line
What is in your handles structure the second time you trigger your callback? From your code it looks to work exactly as it should do.
I have accidentally overwritten handles in the past when I assign the output of some function that used to be the full handles structure, but no long is, to the guidata, but you are passing the full handles structure back which is what you should be doing.
@stalin samuel, it doesn't work like this
@Adam I don't know, how can I see what is in my handles structure ? I think it's a problem of overwriting
Put a breakpoint at the first line of the callback and then take a look at what handles is when you trigger it the second time.

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 18 Aug 2014

Commented:

on 18 Aug 2014

Community Treasure Hunt

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

Start Hunting!