Unrecognized method, property, or field 'value' for class
387 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I am trying to use a switch in Matlab app designer for a uit converter. However when I code the program to change the items in a drop down menu to change when the switch is flipped, i get this message: 'Unrecognized method, property, or field 'value' for class.' I'm not really sure what this means or how to solve it. I have attatched my code file if you would like to look at it and help me out.
thanks in advance!
1 个评论
采纳的回答
Mohammad Sami
2020-5-5
You are using smaller case for value on line 37. just change to upper case as follows.
conversionvalue = app.conversiontypeDropDown.Value;
3 个评论
Eric Sargent
2020-12-9
编辑:Eric Sargent
2020-12-9
You have an extra space at the end of "imperial to metric" in the Items property of your switch.
So you're never getting a logical match because when the switch is on "imperial to metric" its actual value is "imperial to metric " with that extra space at the end and thus will never be equal to your hardcoded comparitive value of "imperial to metric".
Instead, I'd propose you try to match the value to the actual Items.
For example, instead of:
function SwitchValueChanged(app, event)
value = app.Switch.Value;
udc = app.conversiontypeDropDown.Value;
if strcmpi(udc, 'temperature') && strcmpi(value, 'imperial to metric')
app.unitsDropDown.Items = {'fahrenheit to celcius'};
end
end
You could consider:
function SwitchValueChanged(app, event)
value = string(app.Switch.Value);
udc = string(app.conversiontypeDropDown.Value);
if udc == "temperature" && value == string(app.Switch.Items(2))
app.unitsDropDown.Items = "fahrenheit to celcius";
end
end
That way you will always be comparing a value to a possible solution rather than a hardcoded string.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!