Menu command list of colors converted to integers

5 vues (au cours des 30 derniers jours)
Jacob Belouin
Jacob Belouin le 15 Oct 2021
Commenté : Jacob Belouin le 15 Oct 2021
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

Réponses (1)

DGM
DGM le 15 Oct 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)
  1 commentaire
Jacob Belouin
Jacob Belouin le 15 Oct 2021
Man I made this post so i would have to bother you again lol

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by