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 visualizaciones (últimos 30 días)
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

Respuestas (2)

Sachin Ganjare
Sachin Ganjare el 24 de En. de 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 el 24 de En. de 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.

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by