App Designer- How do I get my drop down box to output to Edit Field boxes?
이전 댓글 표시
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
Ahmet Cecen
2018년 3월 23일
Just attach the app itself, this is almost impossible to debug.
Rachael Cowell
2018년 3월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!