Creating Dynamic Vector in Matlab GUI

1 回表示 (過去 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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by