Menu command list of colors converted to integers

5 visualizaciones (últimos 30 días)
Jacob Belouin
Jacob Belouin el 15 de Oct. de 2021
Comentada: Jacob Belouin el 15 de Oct. de 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

Respuestas (1)

DGM
DGM el 15 de Oct. de 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 comentario
Jacob Belouin
Jacob Belouin el 15 de Oct. de 2021
Man I made this post so i would have to bother you again lol

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by