how can i read letters from an input and make them numbers to make an array from those numbers

1 回表示 (過去 30 日間)
Cristian
Cristian 2024 年 12 月 7 日
回答済み: Image Analyst 2024 年 12 月 9 日
i want to make a program in which i need to select depending a cordenate that is in fact a letter like AB,BC,CD...etc but i dont how to make it or if even possible. (my english its not that good my bad)

回答 (2 件)

Walter Roberson
Walter Roberson 2024 年 12 月 7 日
ValidInputs = {'AB', 'BC', 'CD', 'DE', 'AD'};
INPUT = input('enter some letters', 's');
[found, idx] = ismember(lower(INPUT), lower(ValidInputs) );
if ~found
error('invalid input');
end
selected_case_idx = idx;
selected_case = ValidInputs{selected_case_idx};

Image Analyst
Image Analyst 2024 年 12 月 9 日
Try this:
validInputs = {'AB', 'BC', 'CD', 'DE', 'AD'};
selectedIndex = listdlg("PromptString",'Select an option', 'ListString', validInputs)
fprintf('You selected index %d which is %s.\n', selectedIndex, validInputs{selectedIndex});

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by