I am new to Matlab and using the library code for A* algorithm. I am unable to understand the array notation in it. The code snippet is as given below. I am unable to identify that which element it is access with OPEN(1,1), please help me out.

조회 수: 2 (최근 30일)
OPEN[];
OPEN(1,:)=insert_open(xNode,yNode,xNode,yNode,path_cost,goal_distance,goal_distance);
OPEN(1,1)=0;
function new_row = insert_open(xval,yval,parent_xval,parent_yval,hn,gn,fn)
new_row=[1,8];
new_row(1,1)=1;
new_row(1,2)=xval;
new_row(1,3)=yval;
new_row(1,4)=parent_xval;
new_row(1,5)=parent_yval;
new_row(1,6)=hn;
new_row(1,7)=gn;
new_row(1,8)=fn;
end

답변 (2개)

Sachin Ganjare
Sachin Ganjare 2013년 1월 24일
insert_open function is returning a row of values.
OPEN(1,1) means 1st element of the row returned by insert_open function

Walter Roberson
Walter Roberson 2013년 1월 24일
OPEN(1,1) would become new_row(1,1) which is set as 1.
More generally, OPEN(1,K) would become new_row(1,K) as set in the function.
Please re-check the first line. Is it really
OPEN=[];
instead of
OPEN[];
The version without the "=" would not be valid syntax.

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by