Error shows Not enough input arguments
Show older comments
Hello, I got one question and it keeps showing Not enought input arguments as it's error code, and cannot get a proper answer from it.
The questions is to create a logic array with true for any location where the runner is on the Red Team (R) with a running time less than 10.
The Function I wrote is :
function qualifyingIndex=FindQualify(rTeams, rTimes)
FindQualifyLocs=[(rTeams=='G'),(rTimes<10)];
qualifyingIndex=FindQualify.*FindQualifyLocs;
end
and the code to call my function is :
FindQualify(['R','B','R'],[10.1,8,11])
Accepted Answer
More Answers (1)
Walter Roberson
on 7 Aug 2021
qualifyingIndex=FindQualify.*FindQualifyLocs;
Notice in that line you have FindQualify, which is the name of the function that you are defining. That is a request to invoke that same function recursively, but this time passing in no arguments.
Unfortunately there is no documentation as to what the function is intended to do, so I cannot suggest a repair.
2 Comments
Ruoming Xu
on 7 Aug 2021
Walter Roberson
on 7 Aug 2021
[(rTeams=='B'),(rTimes<10)]
rTeams is a vector of length 3. rTimes is a vector of length 3. When you put the two vectors together with [] you get a vector of length 6.
You then try to multiply that vector of length 6 by... something. You are expecting a vector of length 3 as the result.
In order for multiplication of 1 x 6 vector to give a 1 x 3 result, you would need to be using
A is some 3 x 6 array
result = (A * FindQualifyLocs.').'
where A is some 3 x 6 array. Using * between a 3 x 6 and a (1 x 6 transposed to be 6 x 1) would give 3 x 1, and you would transpose that to get a 1 x 3.
But what should that array A be? I do not know.
I would suggest to you that [(rTeams=='B'),(rTimes<10)] is the wrong thing to compute. https://www.mathworks.com/help/matlab/ref/and.html
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!