App Designer: Listbox- update items to select based on previous functions and plot

24 ビュー (過去 30 日間)
Hello, I am building a matlab app that will sort through a folder of csv data, analyze, and plot it based on user inputs which specify how the data should be analyzed. I have successfully gotten the data to be imported and sorted, and created a cell that holds any data which was deemed to not fall into any of the expected categories. Alongside that cell that holds the "extra" data, I have another cell which holds the file name of that "extra" data.
I would like the bottom listbox, named "other data" to display the names of the extra data, so each item in the listbox is the file name, for which I can then select that data, and have it be plotted in an axis which will be on the right.
As the top functionality of the app imports and sorts the data, I initilize two cells:
other=cell(1,1);
otherNames=cell(1,1);
If the data file being sorted does not fall into a category as specified by the "Experiments" listbox, then the imported CSV data goes into other, and the CSV's name goes into otherNames as a string. Each element of other is a 2D array of doubles, and each element of otherNames is a string [or character array, honestly unsure which right now]. Each element corresponds to a different data file that did not get sorted into one of the specified categories.
So I now have created a callback for the "Other Data" listbox that looks like the following snipped of code, where the the property, extraNames=otherNames.
otherDataNames=app.extraNames;%Intending to grab the cell of names from the properties list
if isa(otherDataNames,'double')%If no name was placed in the cell, the cell contains a 0...
app.OtherDataListBox.Items={'No Extra Data'};drawnow;%...so make the only item in the listbox a message
else
app.OtherDataListBox.Items=otherDataNames;drawnow;%else, if the cell contains strings of file names, set the items in the list box = the file names
end
app.otherSel = app.OtherDataListBox.Value;%set the property "otherSel" = the value chosen by this listbox
I included drawnow because at each step of data importing and sorting, I had that textbox in the app update with what step had finished using
app.ImportProgressLabel.Text="Data Import Complete";drawnow;
TLDR: What is the correct way of using a cell of strings, generated by a button push, to create/update the list of items in a listbox using app designer? It seems like the documentation for uifigure list boxes suggest that setting a cell of strings = to the Items property is correct :/
and FYI this is what the cell element looks like, so I believe it is even in the correct format

採用された回答

Megan Renny
Megan Renny 2022 年 4 月 6 日
編集済み: Megan Renny 2022 年 4 月 13 日
After working with app designer another week, I realize that the listbox call back function is for when a value in the listbox is selected/changed, not for initalizing the values of the listbox. This was a silly mistake to make!

その他の回答 (0 件)

カテゴリ

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by