MATLAB: Creating a table using a drop-down menu

app designerMATLAB

I am trying to place a 1×3 vector of integers into the Item data associated with each option (let's say N is the number of options) in a drop-down menu, then I want to create an output Nx2 matrix and plot it in the figure on the right panel.
Essentially, I'm trying to set N number of points (N defined by the slider value) in a flight plan by assigning data (altitude, velocity, and time) to the item data of each item in the drop-down menu, then concatenate all of the item data vectors and plot it. Everytime I attempt to assign values to the itemdata of a given option, it sets the number of items to 1, leaving only one option to select in the dropdown.
Any suggestions?

Best Answer

I think I figured out the main issue I was having. It may not be the most efficient (code section posted below along with full file), but I assigned a 1xN cell array to the component's itemdata (N=number of components) where each entry in the cell array is a 1x2 cell with a string vector and a 1x3 zero vector (this could be changed to as long as one wants). This allows me to assign a set of numbers to each unique option while each option's value (what's seen by the user) remains as just the string vector (I realized that the value and itemdata are linked; each value is simply the first string found in the itemdata for the given entry). However, I still need to figure out how to plot each point of data on the axes in the right panel, but I believe I have a way to do so.
Issues I need to work out:
  • Everytime I edit the altitude, velocity, or time of a given option, it resets the option selected to 1, but it doesn't change the data associated with point 1 as long as I don't press ENTER
  • I'd like to be able to see all of the data at once in a table, so I need to figure out how to display all the assigned data to a table as I make changes.
% Value changed function: AltitudekmEditField
function AltitudekmEditFieldValueChanged(app, event)
idx = str2num(app.SelectDataPointDropDown.Value{1}(end));
value = app.AltitudekmEditField.Value;
value2 = app.AirspeedMachEditField.Value;
value3 = app.TimehrEditField.Value;
app.SelectDataPointDropDown.ItemsData{idx}{2} = [value;value2;value3];
end
% Value changed function: AirspeedMachEditField
function AirspeedMachEditFieldValueChanged(app, event)
idx = str2num(app.SelectDataPointDropDown.Value{1}(end));
value = app.AltitudekmEditField.Value;
value2 = app.AirspeedMachEditField.Value;
value3 = app.TimehrEditField.Value;
app.SelectDataPointDropDown.ItemsData{idx}{2} = [value;value2;value3];
% Regenerate Table with new additions
end
% Value changed function: TimehrEditField
function TimehrEditFieldValueChanged(app, event)
idx = str2num(app.SelectDataPointDropDown.Value{1}(end));
value = app.AltitudekmEditField.Value;
value2 = app.AirspeedMachEditField.Value;
value3 = app.TimehrEditField.Value;
app.SelectDataPointDropDown.ItemsData{idx}{2} = [value;value2;value3];
end
% Value changed function: SelectDataPointDropDown
function SelectDataPointDropDownValueChanged(app, event)
value = app.SelectDataPointDropDown.Value;
app.AltitudekmEditField.Value = value{2}(1);
app.AirspeedMachEditField.Value = value{2}(2);
app.TimehrEditField.Value = value{2}(3);
end