How can i use a switch and a drop down menu? matlab appdesigner

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.

 Risposta accettata

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 Commenti

Ahhh I see.
Thank you so much mate, I appreciate your help. would you still like me to attatch my code file?
No need to attach your code...but next time, it would be preferrable to attach it rather than a screen shot.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by