Not enough input arguments. Error in get_Result (line 6) if(answers{i}.charAt(j)==correct.charAt(j))
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Rajanya
le 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Filename Construction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!