App Designer- How do I get my drop down box to output to Edit Field boxes?
Show older comments
I can't figure out how to get my drop down boxes to work for multiple options. Only the code with 1 value works. I know I have tried more variations but I'm frustrated and these are the only 2 I remember right now.
The error I got with "if, elseif, else" was "matrix dimensions must agree" after running the app and selecting the second or third options but the first still works.
The app.A125_1, etc are the Edit Field (Numeric) boxes that I am setting the input for.
Working code: % Value changed function: Material2DropDown function Material2DropDownValueChanged(app, event) value = app.Material2DropDown.Value
app.Mat2.Value = app.Material2DropDown.Value;
if value == 'Brick, unglazed'
app.A125_2.Value = 0.03
app.A250_2.Value = 0.03
app.A500_2.Value = 0.03
app.A1000_2.Value = 0.04
app.A2000_2.Value = 0.05
app.A4000_2.Value = 0.07;
end
end
First failed attempt: % Value changed function: Material1DropDown function Material1DropDownValueChanged(app, event) value = app.Material1DropDown.Value app.Mat1.Value = app.Material1DropDown.Value;
if value == 'Brick, unglazed'
app.A125_1.Value = 0.03
app.A250_1.Value = 0.03
app.A500_1.Value = 0.03
app.A1000_1.Value = 0.04
app.A2000_1.Value = 0.05
app.A4000_1.Value = 0.07;
if value == 'Brick, unglazed, painted'
app.A125_1.Value = 0.01
app.A250_1.Value = 0.01
app.A500_1.Value = 0.02
app.A1000_1.Value = 0.02
app.A2000_1.Value = 0.03
app.A4000_1.Value = 0.04;
if value == 'Carpet 3.2mm pile height'
app.A125_1.Value = 0.05
app.A250_1.Value = 0.05
app.A500_1.Value = 0.10
app.A1000_1.Value = 0.20
app.A2000_1.Value = 0.30
app.A4000_1.Value = 0.40;
end
end
Second Failed attempt: % Value changed function: Material1DropDown function Material1DropDownValueChanged(app, event) value = app.Material1DropDown.Value app.Mat1.Value = app.Material1DropDown.Value;
if value == 'Brick, unglazed'
app.A125_1.Value = 0.03
app.A250_1.Value = 0.03
app.A500_1.Value = 0.03
app.A1000_1.Value = 0.04
app.A2000_1.Value = 0.05
app.A4000_1.Value = 0.07;
elseif value == 'Brick, unglazed, painted'
app.A125_1.Value = 0.01
app.A250_1.Value = 0.01
app.A500_1.Value = 0.02
app.A1000_1.Value = 0.02
app.A2000_1.Value = 0.03
app.A4000_1.Value = 0.04;
else value == 'Carpet 3.2mm pile height'
app.A125_1.Value = 0.05
app.A250_1.Value = 0.05
app.A500_1.Value = 0.10
app.A1000_1.Value = 0.20
app.A2000_1.Value = 0.30
app.A4000_1.Value = 0.40;
end
end
<<

>>
2 Comments
Ahmet Cecen
on 23 Mar 2018
Just attach the app itself, this is almost impossible to debug.
Rachael Cowell
on 23 Mar 2018
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB 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!