Creating Dynamic Vector in Matlab GUI

3 次查看(过去 30 天)
Phil
Phil 2013-12-3
评论: Simon 2013-12-4
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!

回答(1 个)

Simon
Simon 2013-12-3
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 个评论
Phil
Phil 2013-12-3
can you explain how to initialize the cell array on order to save the first file name inputted?
Simon
Simon 2013-12-4
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!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by