Creating a table using a drop-down menu

조회 수: 3 (최근 30일)
Matthew Dick
Matthew Dick 2020년 4월 18일
댓글: Matthew Dick 2020년 4월 20일
I am trying to place a 1x3 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?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2020년 4월 20일
Matthew - please show us the code that is assigning "values to the itemdata of a given option" so that we can understand how "it sets the number of items to 1".
Matthew Dick
Matthew Dick 2020년 4월 20일
Thank you very much for the response, but I managed to figure it out after putting my nose to the grindstone a little longer. Have a great day!

댓글을 달려면 로그인하십시오.

채택된 답변

Matthew Dick
Matthew Dick 2020년 4월 20일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by