Not enough input arguments. Error in get_Result (line 6) if(answers​{i}.charAt​(j)==corre​ct.charAt(​j))

3 visualizzazioni (ultimi 30 giorni)
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'

Risposte (1)

Rajanya
Rajanya il 19 Mar 2025
'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.

Categorie

Scopri di più su Filename Construction in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by