Not enough input arguments. Error in get_Result (line 6) if(answers{i}.charAt(j)==correct.charAt(j))
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Rajanya
am 19 Mär. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Filename Construction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!