Error "Argument must contain a string"
1 回表示 (過去 30 日間)
古いコメントを表示
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;
0 件のコメント
回答 (1 件)
Arnab Sen
2015 年 12 月 29 日
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!