Creating Dynamic Vector in Matlab GUI

1 view (last 30 days)
Phil
Phil on 3 Dec 2013
Commented: Simon on 4 Dec 2013
I have an image upload box in my Matlab GUI. In this GUI, I would like to create a vector that adds the actual file name of each of these images that I have uploaded. For example: If I upload 5 images I want a vector with 5 file-name listed. I need to track what files names have been called in the past for other parts of my code. I have tried using a counter loop type operation with no success. Any suggestions are much appreciated!

Answers (1)

Simon
Simon on 3 Dec 2013
Hi!
Use a cell array for your file names (strings). Each time you upload a new image you add one cell to the array. After that store the array with "guidata", so that you can get it back every time a new image is uploaded.
  2 Comments
Phil
Phil on 3 Dec 2013
can you explain how to initialize the cell array on order to save the first file name inputted?
Simon
Simon on 4 Dec 2013
Hi!
The GUI has an opening function that is executed before the GUI is shown. I place my initial values there:
handles.FileNames = {};
% Update handles structure
guidata(hObject, handles);
Afterwards in the upload callback function you can add the file name like
handles.FileNames = [handles.FileNames; CurrentName];
Don't forget to store "handles" at the end of the callback function!

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!