function plot_particles(S,real,range_pos,Estimate_bestparticle,Estimate_weightedmean,Estimate_robustmean,parameter) % function that plots the position of all the particles W=S(4,:); % matrix of weights M=length(W); % M is the number of particles figure; hold on; %plot(S(1,:),S(2,:),'.');\ plot(real(1),real(2),'cs','MarkerEdgeColor','c','MarkerFaceColor','c','MarkerSize',12); %axis equal; plot(Estimate_bestparticle(1),Estimate_bestparticle(2),'bo','MarkerEdgeColor','b','MarkerFaceColor','b','MarkerSize',12); plot(Estimate_weightedmean(1),Estimate_weightedmean(2),'ro','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',12); plot(Estimate_robustmean(1), Estimate_robustmean(2),'mo','MarkerEdgeColor','m','MarkerFaceColor','m','MarkerSize',12); scatter(S(1,:),S(2,:),15,S(4,:),'o','filled'); colorbar; plot(Estimate_bestparticle(1),Estimate_bestparticle(2),'bo','MarkerEdgeColor','b','MarkerFaceColor','b','MarkerSize',12); plot(Estimate_weightedmean(1),Estimate_weightedmean(2),'ro','MarkerEdgeColor','r','MarkerFaceColor','r','MarkerSize',12); plot(Estimate_robustmean(1), Estimate_robustmean(2),'mo','MarkerEdgeColor','m','MarkerFaceColor','m','MarkerSize',12); plot(real(1),real(2),'cs','MarkerEdgeColor','c','MarkerFaceColor','c','MarkerSize',12); legend('Real position','Estimate bestparticle','Estimate weightedmean','Estimate robustmean') %axis([-range_pos/2,range_pos/2,-range_pos/2,range_pos/2]); axis([-2,20,-2,20]); switch parameter case 1 drawwall; case 2 drawRF; case 3 drawwall; drawRF; end