spell cheaker stuck in loop
古いコメントを表示
Ive got a simple enough problem code has to make sure user input is correct but Ive made a very ugly while loop and its not working at all probably needs to be completely redone, any tips are appreciated
if true
InputString = input('Input:', 's');
lenghtInput = length(InputString);
test = 'UuGgCcAa';
i = 1;
j = 1;
c = 1;
correctInput = false;
while correctInput ~= true
if InputString(i) ~= test(j) || j == lenghtInput
++j;
++c;
display(i)
if c == 3
c = 0;
i = i + 1;
end
end
correctInput = true;
end
%code
%it needs to check the only characters used are in the test variable
4 件のコメント
riley collins
2018 年 5 月 7 日
Walter Roberson
2018 年 5 月 7 日
++j is not valid MATLAB syntax.
Why not just use strcmp() or strcmpi() ?
riley collins
2018 年 5 月 7 日
編集済み: riley collins
2018 年 5 月 7 日
KSSV
2018 年 5 月 7 日
If you want to compare strings have a look on strcmp and strcmpi.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!