GBFS algorithm (how to find the neighbor of case of a matrix)
2 views (last 30 days)
Show older comments
Hello, I need a help please for my code matlab : I cearte a matrix 2*3 and I want to search for each iteration the minimum of the neigbhor of the case starting with case source (1,1)=1 to case destination (2,3) and then I want to trace the path with each minimin found by using the index of this latest
here my code the problem that I had is I cant calculate the neigbhor successively to the first minumin founded. I arrived only to find the neighbor of all the case of matrix.
clear all;
clc;
close all;
G=[1 2 3; 4 5 6];
for x_in=1:2
for y_in=1:3
res=checkedges(x_in,y_in,2,3); % in order to simplify the calculation, we extract all the points in which we cannot pass
if res
%% Search of neigbors of each node
s = size(G);
B = zeros(s);
n = numel(G);
out = cell(s);
for ii = 1:n
B(ii) = 1;
out{ii} = G(bwdist(B,'ch') == 1);
[minimum(ii) I(ii)]=min(out{ii});
B(ii) = 0;
[PX PY]=find(G==minimum(ii));
hold on ,plot(PX,PY)
end
end
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!