how can i read letters from an input and make them numbers to make an array from those numbers
30 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
回答(2 个)
Walter Roberson
2024-12-7,6:21
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};
0 个评论
Image Analyst
2024-12-9,4:17
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});
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!