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 Ansichten (letzte 30 Tage)
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

Antworten (2)

Sachin Ganjare
Sachin Ganjare am 24 Jan. 2013
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 am 24 Jan. 2013
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.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by