Menu command list of colors converted to integers

5 ビュー (過去 30 日間)
Jacob Belouin
Jacob Belouin 2021 年 10 月 15 日
コメント済み: Jacob Belouin 2021 年 10 月 15 日
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

回答 (1 件)

DGM
DGM 2021 年 10 月 15 日
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 件のコメント
Jacob Belouin
Jacob Belouin 2021 年 10 月 15 日
Man I made this post so i would have to bother you again lol

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by