Creating Dynamic Vector in Matlab GUI
3 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!