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 views (last 30 days)
Show older comments
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
1 Comment
Answers (2)
Sachin Ganjare
on 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
0 Comments
Walter Roberson
on 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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!