Menu command list of colors converted to integers
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone,
Taking a Matlab class this semester and I was looking for a jumping off point for my assignment. I have to use a menu command (has to be menu even though matlab says its no longer recomended) to list off 10 color options. The colors have a number value that is also 1:10, but I dont know how to assign the user selected color to the number value. The program is supposed to calculate the value and range of a resistor, but I can't get to the function portion without being able to assign values to the user selection.
Thanks
0 Commenti
Risposte (1)
DGM
il 15 Ott 2021
I know this is part of the other question, but to clarify, the menu() command simply returns the index of the selected element within the list of choices. In other words, there really isn't a need to explicitly define the relationship between the color list and the values 1:10; those values are already the indices within the color list itself.
colornames = {'john deere yellow','international yellow','new holland yellow'};
% this will return a scalar integer from 1 to 3
idx = menu('yeah i know you said yellow, but which one?',colornames)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!