how to get a value from a drop down menu in matlab
Show older comments
Im trying to programmatically build a UI, im doing it this way because I have some complicated surfaces that I want to calculate and I want to do it for thousands of files. The matlab code do this is done, but I have a few pop up messages and input boxes that work, its clunky to say the least so im trying to clean it up with uifigure. Right now in my regular matlab code that I have been building, an input box pops up that asks if you want to and how to save data (i.e. either as a csv or txt file), if you want to move data and what type of surface you want to build. If a "calculated surface" if chosen, another input box pops up and asks if you want a surface with lowess smoothing or cubic interpolation, this only pops up if you choose the right option.
In uifigure im trying to duplicate this, I have a drop down that asks what kind of surface you want to create, if a "calculated surface" is chosen, I want another drop down menu to show up asking what type of calculated surface you want to make. This is where im having trouble and I need to figure it out before I can add in my other calculations. When I select a drop down option, dd1.Value is not changing, it stays at 0, in the switch function at the bottom im trying to say if dd1.Value = 2 then dd3.Visible = 'on'. When I run it, everything works fine however dd1.Value isnt changing depnding on user selection and im not sure where im going wrong or what I need to add. Any advice is appreciated. Thanks!
close all
fig = uifigure("Name", 'Single Beam Processing', 'Position', [30,75,1450,750]);
panel1 = uipanel(fig, "Position", [50,350,200,350]);
panel1.Title = "Program Setup";
panel1.TitlePosition = 'centertop';
panel1.FontSize = 14;
txtbox1 = uieditfield(panel1,"Text", "Position", [10,290,180,30], "Value", "Operator Name");
dd1 = uidropdown(panel1, 'Position', [10,250,180,30]);
dd1.Items = ["Choose Surface Type", "Depth", "Calculated Surface", "Fitted Plane", "Corrected Points", "None"];
dd1.ItemsData = [0 1 2 3 4 5];
dd1.Visible = 'on';
dd1value = dd1.Value;
dd2 = uidropdown(panel1, 'Position', [10,210,180,30]);
dd2.Items = ["Choose Save Options", "Save as CSV", "Save as txt"];
dd2.ItemsData = [0 1 2];
dd1.Visible = 'on';
dd2value = dd2.Value;
dd3 = uidropdown(panel1, 'Position', [10,170,180,30]);
dd3.Items = ["Choose Smoothing Type", "Lowess", "Cubic Interpolation"];
dd3.ItemsData = [0 1 2];
dd3.Visible = 'off';
switch dd1value
case 2
dd3.Visible = 'on';
otherwise
dd3.Visible = 'off';
end
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Programmatically 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!