fprintf('Beginning to run %s.m ...\n', mfilename);
allSports = {'hockey','tennis', 'cricket', 'football', 'racing', 'golf', 'Cody'};
thisSport = 'Football';
result = select(thisSport, allSports)
fprintf('%s is sport #%d.\n', thisSport, result);
fprintf('Done running %s.m.\n', mfilename);
function result = select(thisSport, allSports)
thisSport = lower(thisSport);
allSports = lower(allSports);
[~, result] = ismember(thisSport, allSports)
end
2 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/713443-how-can-i-compare-the-multiple-strings#comment_1255558
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/713443-how-can-i-compare-the-multiple-strings#comment_1255558
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/713443-how-can-i-compare-the-multiple-strings#comment_1256213
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/713443-how-can-i-compare-the-multiple-strings#comment_1256213
サインインしてコメントする。