Not enough input arguments. Error in get_Result (line 6) if(answers{i}.charAt(j)==correct.charAt(j))
3 ビュー (過去 30 日間)
古いコメントを表示
function[count]=get_Result(answers,correct)
count=[0 0 0 0 0];
for i=1:5
for j=1:5
if(answers{i}.charAt(j)==correct.charAt(j))
count(i)=count(i)+1;
end
end
end disp('the answers are: ',count);
end
anyone can help me this function. this function can compare between each character of string in a cell with a string and return a vector of number matches.
for eg.we have {'ttfft','tttff','tftft','ttfft,'fffff'} and we have a string 'ttftf'
0 件のコメント
回答 (1 件)
Rajanya
2025 年 3 月 19 日
'charAt' method is not available in MATLAB (it's a Java method!).
As I understand from the code, the function attempts to check the number of character matches in every string of the cell array 'answers' with 'correct'. To extract the character at a particular position of a string, you can just index the string with the required position [1-indexed] using parantheses () - see here.
Thus, the changed 'if' check would be like this -
if(answers{i}(j)==correct(j))
...
end
Thanks.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Filename Construction についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!