Dear MATLAB users,
I am attempting to create an app with App Designer (2019a) which does the following:
- Loads an Excel file (text/string data only) with user file selection
- Populates ListBox1 with first row of Excel file
- Uses the value selected by the user from ListBox1 to populate ListBox2 with options listed "below"/in rows below option selection (from Excel sheet).
- This selection continues until all options from the first row have been used.
A simplified example of my Excel sheet is as follows:
I have successfully loaded the excel sheet and populated ListBox1 (albeit I believe inefficiently). But cannot get "strcmp" to return a "1" for the row where the value selected appears in the Excel sheet. Furthermore, if I try to make my Excel data when converted to a cell array ("O") as a global variable ("app.O") the population of my first ListBox does not work. My call backs for the "LoadExcelTemplate" pushbutton and ListBox1 are as follows:
% Button pushed function: LoadExcelTemplateButton
function getexcelfile(app, event) [file,path]=uigetfile('../*.xlsx'); app.OPS=readtable(file,'ReadVariableNames',0,'TextType','string','TreatAsEmpty',{''}) numOPS=width(app.OPS) set(app.ListBox1,'Enable','on') for i=1:numOPS O{i}=app.OPS(:,i); app.ListBox1.Items(i)=cellstr(O{i}{1,1}) end end % Value changed function: ListBox1
function list1items(app, event) OP1 = app.ListBox1.Value; numOPS=width(app.OPS); for i=1:numOPS O{i}=app.OPS(1,i); end x=strcmp(O,OP1); end
Best Answer