Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

please help me to remove the error .... when i execute my code following error is occurd "Matrix dimensions must agree. Error in ==> ACO_FOR_EDGE at 90 if ant_pos_idx & ant_search_range_temp == ant_memory;"

1 vue (au cours des 30 derniers jours)
lavi
lavi le 17 Juin 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
im1=double(imread('D:\l.jpg')); im=rgb2gray(im1); [m n]=size(im);
% total no. of ants % ant_total_num = round(sqrt(m*n)); ant=zeros(1,ant_total_num); % ant's position ant_pos_idx = zeros(ant_total_num, 2);
search_mode = '8';
pixel_visibility=zeros(m,n);
% pheromoe_matrix=zeros(m,n);%
pheromoe_matrix= zeros(m,n);
for i=1:m
for j=1:n
pheromoe_matrix(i,j) = 0.01;
end
end
% initialisation of parameters % alpha = 1; beta = 10; T=.08; pheromone_evap_rate = 0.05; im_max=255; % B=.45; %k=20;
A =25;
memory_length = round(rand(1).*(1.15*A-0.85*A)+0.85*A); % memory length
ant_memory = zeros(ant_total_num, memory_length);
%rand('state', sum(clock)); temp = rand(ant_total_num, 2); ant_pos_idx(:,1) = round(1 + (m-1) * temp(:,1)); %row index ant_pos_idx(:,2) = round(1 + (n-1) * temp(:,2)); %column index
for ant_idx = 1:ant_total_num
ant_current_row_idx = ant_pos_idx(ant_idx,1);
ant_current_col_idx = ant_pos_idx(ant_idx,2);
rr = ant_current_row_idx;
cc = ant_current_col_idx;
if search_mode == '8'
rr = ant_current_row_idx;
cc = ant_current_col_idx;
ant_search_range_temp = [rr-1 cc-1; rr-1 cc; rr-1 cc+1; rr cc-1; rr cc+1; rr+1 cc-1; rr+1 cc; rr+1 cc+1];
end
for i=2:m-1
for j=2:n-1
im2 = [im(i - 1, j - 1) - im(i + 1, j + 1) , im(i - 1, j + 1)-im(i + 1, j - 1) , im(i, j - 1) - im(i, j + 1), im(i-1,j)-im(i+1,j)];
pixel_visibility(i,j) = (1/im_max) * max(im2);
end
end
for i=1:m;
for j=1:n;
num(i,j)=((pheromoe_matrix(i,j)) * (pixel_visibility(i,j)^10));
end
end
for u=1:ant_search_range_temp;
for v=1:ant_search_range_temp ;
deno(u,v)=0;
mul(u,v)= ((pheromoe_matrix(u,v)) * (pixel_visibility(u,v)^10));
deno(u,v)=deno(u,v)+mul(u,v);
end
end
for k=1:ant_total_num; for i=1:m; for j=1:n; if ant_pos_idx & ant_search_range_temp == ant_memory; prob(i,j)=o else prob(i,j)=num(i,j)/deno(u,v); end
end
end
end
end

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by