Error "Argument must contain a string"

1 view (last 30 days)
Ken
Ken on 7 Dec 2015
Answered: Arnab Sen on 29 Dec 2015
I am trying to code a program to find the least path for a robot but get above error. My code is:
while(currentCell ~= SearchStart)
%Take the cell where you are right now and its 8 neighbours, and store it in a variable
u=currentCell(1);
v=currentCell(2);
neighborhood8 = SearchSolution(v-1:v+1, u-1:u+1);
%Assign an Inf value to the cell you are on right now, so that it doesn't interfere when finding the minimum of the neighborhood array
neighborhood8(2,2) = Inf;
%end
%end
%Find the minimum element and its index in the 8-neighborhood
[path(i+1,1), path(i+1,2)] = find(neighborhood8==min(min(neighborhood8)));
%Increment the index of the OptimalPath array last element
i = i + 1;
end
OptimalPath = path;

Answers (1)

Arnab Sen
Arnab Sen on 29 Dec 2015
I understand that you are getting an error while trying to execute the code. This kind of issue might arises while there is a naming conflict among the user defined function or variable and in built function or variable.
I notice that in your code you use 'path' as a 2-D matrix. But MATLAB has an inbuilt function 'path' which accepts string. I suspect MATLAB treats your 'path' matrix as 'path' function call and throws an error as it does not get a string as input argument. Try change the name of the matrix 'path' some other variable. You can verify which function/variable is considered by MATLAB by executing the following command in MATLAB command window:
>>which -all path

Tags

Community Treasure Hunt

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

Start Hunting!