How can i use a switch and a drop down menu? matlab appdesigner
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ashwin Palanisamy
el 4 de Mayo de 2020
Comentada: Geoff Hayes
el 4 de Mayo de 2020
For my unit converter im trying to have it so that i have a switch that can select metric to imperial or imperial to metric, and have a drop down menu that will allow th euser to slect what they wish to convert eg, temperature, distance, mass. However, I dont really know how to code a && in the callback function that will allow me to change the items in the third drop down menu. for example, to make it so that if the user changes the switch to 'metric to imperial' and selects length. how do I make it so the second drop down menu will take into considration both of these user inputs and display 'cm to inch' so on and so forth?
I will provide a screenshot of my code and please try not to facepalm. I am new to matlab programming.
0 comentarios
Respuesta aceptada
Geoff Hayes
el 4 de Mayo de 2020
Ashwin - one problem with your conversiontypeDropDownValueChanged callback, you are using the same variable name for to represent two different values
value = app.converstiontypeDropDown.Value;
value = app.Switch.Value;
if strcmpi(value,'temperature') && strcmpi(value, 'metric to imperial')
% etc.
end
Try renaming the variables to distinguish one from the other and to give you an idea as to what each represents.
conversionValue = app.converstiontypeDropDown.Value;
switchValue = app.Switch.Value;
if strcmpi(conversionValue,'temperature') && strcmpi(switchValue, 'metric to imperial')
% etc.
end
Also, please include attach your code rather than a screen shot of it.
2 comentarios
Geoff Hayes
el 4 de Mayo de 2020
No need to attach your code...but next time, it would be preferrable to attach it rather than a screen shot.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!