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
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!