필터 지우기
필터 지우기

Error "Argument must contain a string"

조회 수: 1 (최근 30일)
Ken
Ken 2015년 12월 7일
답변: Arnab Sen 2015년 12월 29일
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;

답변 (1개)

Arnab Sen
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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by