App designer, making components visible

조회 수: 19 (최근 30일)
MIchael Brennan
MIchael Brennan 2020년 5월 5일
댓글: Image Analyst 2020년 5월 5일
im having trouble turning on and off visiblity of a dropdown component and a button component
This error has come up for "switch expression must be a scalar or a character vector
app.SelectfeildDropDown.ValueChangedFcn
app.SelectfeildDropDown.Items
for
app.SelectfeildDropDown.Value
nothing happens we i change the value on the GUI
% Callbacks that handle component events
methods (Access = private)
% Value changed function: SelectfeildDropDown
function SelectfeildDropDownValueChanged(app, event)
switch(app.SelectfeildDropDown.DropDown.value)
case 'select'
case 'Tempreture'
app.MetrictoImperialButton.Visible
app.DropDown.Visible
case 'Length'
app.MetrictoImperialButton.Visible
app.DropDown.Visible
case 'Mass'
app.MetrictoImperialButton.Visible
app.DropDown.Visible
end
end
end

채택된 답변

Image Analyst
Image Analyst 2020년 5월 5일
편집: Image Analyst 2020년 5월 5일
You can't switch on the function name. You have to switch on the "Value" property, not the callback function's name, like:
switch app.SelectfeildDropDown.Value
Check spelling -- did you mean field instead of feild?
Then, I think you need to actually set the Visible property to something to show or hide it. So do something like
app.DropDown.Visible = 1; % 1 to show. 0 to hide.
Or maybe they use 'on' and 'off' instead of 1 and 0. They are inconsistent about that (at least in GUIDE they were). So if 1 and 0 don't work, try 'on' and 'off'
  댓글 수: 2
MIchael Brennan
MIchael Brennan 2020년 5월 5일
Thanks I managed to work it out, it was supposed to be switch app.SelectionfeildDropDown.Value
But i also needed to toggle the visibility on and off
Image Analyst
Image Analyst 2020년 5월 5일
I guess I must have been posting that same solution at the very same time you were figuring it out on your own. But glad it's fixed.

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

추가 답변 (1개)

MIchael Brennan
MIchael Brennan 2020년 5월 5일
This is what i wanted
  댓글 수: 1
MIchael Brennan
MIchael Brennan 2020년 5월 5일
for case 'Length' & case 'Mass" they should be identical to case 'Tempreture

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

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by