Matlab app development for loads in structure

6 views (last 30 days)
Warren
Warren on 18 Dec 2023
Commented: Kamal on 13 Jun 2025
I am currently developing a software that can solve dead load, live load, earthquake load and live load. im having a problem on the dropdown menu part, it always pick all the values in the dropdown not just one, how to fix it?
  2 Comments
Kamal
Kamal on 13 Jun 2025
To fix the dropdown issue in your MATLAB app, ensure you’re using the ValueChangedFcn callback properly. In App Designer, use app.DropDown.Value to get the selected value, not Items, which returns all options. For single selection, confirm the dropdown’s MultiSelect property is set to false. If it's picking all values, you might be unintentionally using a multi-select component or incorrect callback logic. Double-check that you're assigning and retrieving only the selected value and not looping through the entire list. Correct usage of callbacks and properties will resolve the issue effectively.

Sign in to comment.

Answers (1)

Pratyush
Pratyush on 18 Dec 2023
Hi Warren,
I understand that your dropdown menu is selecting all the values instead of just one. It seems there might be an issue with how you're handling the ValueChanged callback or how the dropdown menu is being populated.
When you add a dropdown component to your app, make sure you're setting its properties correctly. The 'Items' property should contain a cell array of options you want to display.
app.DropDown.Items = {'Option1', 'Option2', 'Option3'};
The dropdown menu has a ValueChanged callback that is triggered whenever a selection is made. Make sure you're using the 'ValueChangedFcn' property to define the callback function properly.
% Code to set up the ValueChangedFcn during app construction
app.DropDown.ValueChangedFcn = createCallbackFcn(app, @DropDownValueChanged, true);
% Callback function for the dropdown menu
function DropDownValueChanged(app, event)
value = app.DropDown.Value;
% Now 'value' holds the currently selected dropdown item
% Insert your code to handle the dropdown selection here
end
The dropdown by default allows only single selection. If it seems like it's selecting all values, it might be a misunderstanding of how the 'Value' property and ValueChanged callback are being used.
Make sure you're not accidentally resetting the dropdown's 'Value' property to all items in your code.
Check if there are any loops or conditions that are causing the dropdown to repopulate or reset incorrectly.
Verify that the 'Value' property of the dropdown is being used to get the selected item, not the 'Items' property, which contains all the options.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!