GBFS algorithm (how to find the neighbor of case of a matrix)

조회 수: 1 (최근 30일)
Mouna SAMAALI
Mouna SAMAALI 2021년 3월 3일
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개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by