www.pudn.com > PSOofFLC.zip > visu_PSO.m, change:2016-06-13,size:2364b


    p_ident = squeeze(swarm(gbest, 3, :)); 
    writeweights; %%update weights and write to FIS 
%% figure(1) 
fig1=figure(1); 
set(fig1,'Position', [800 300 600 400]) 
    visu=2; 
    u0uc =  242.5000; pt=55; speed0=0; slope=0; 
    run_sim; 
    subplot(2,1,1) 
    hold(gca,'on'); 
    pl_visu(iter,1)=plot(Tout,Yout(:,4),'b','Linewidth',2); 
    hold(gca,'off'); 
    grid on; 
    ylabel('[km/h]'); grid on; 
    title('vehicle speed'); 
    subplot(2,1,2) 
    hold(gca,'on'); 
    pl_visu(iter,2)=plot(Tout,-Yout(:,5),'b','Linewidth',2); 
    hold(gca,'off'); 
    grid on; 
    xlabel('time [s]'); grid on; 
    ylabel('[A]'); grid on; 
    if (iter>1) 
        set(pl_visu(iter-1,:),'Visible','off') 
    else 
         set(pl_visu(iter,2),'Color','red') 
    end 
     set(pl_visu(1,:),'Visible','on') 
     legend([num2ordinal(1) ' iteration'], [num2ordinal(iter) ' iteration']); 
     title('Battery current'); 
  
%% figure(4) 
for d=1:num_of_D, 
 
    if d>0 && d<21 
        limmax(d)=1; 
        limmin(d)=-1;  
    end 
    if d>20 && d<29 
        limmax(d)=1; 
        limmin(d)=0;  
    end 
 
end 
fig4=figure(4); 
set(fig4,'Position', [50 350 800 600]) 
kolumny=4; 
rzedy=ceil(num_of_D/(kolumny*2)); 
if iter==1 
    for idx=1:num_of_D/2; 
        ah(idx)=subplot(rzedy,kolumny,idx); 
    end 
    for iah=1:length(ah); 
        ah(iah).OuterPosition(3)=0.95/kolumny; 
        ah(iah).OuterPosition(1)=(mod(iah-1,kolumny))/kolumny; 
        ah(iah).OuterPosition(4)=0.95/rzedy; 
        ah(iah).OuterPosition(2)=1-(ceil(iah/kolumny))/rzedy; 
    end 
end 
for idx=1:length(ah); 
    hold(ah(idx),'on'); 
    pl4(iter,idx,:)=plot(ah(idx),swarm(:,1,idx*2-1)-swarm(:,2,idx*2-1),swarm(:,1,idx*2)-swarm(:,2,idx*2),'g*',swarm(gbest,3,idx*2-1),swarm(gbest,3,idx*2),'g*'); 
    hold(ah(idx),'off'); 
    grid(ah(idx),'on'); 
    if iter>(1)   
        set(pl4(iter-1,idx,:),'Visible','off') 
        set(pl4(iter,idx,1),'Color','black') 
        set(pl4(iter,idx,2),'Color','red') 
    end 
    set(pl4(1,idx,:),'Visible','on') 
    xlim(ah(idx),[limmin(idx*2-1) limmax(idx*2-1)]); 
    ylim(ah(idx),[limmin(idx*2) limmax(idx*2)]); 
    set(ah(idx),'XTick',[-1:0.2:1]) 
    set(ah(idx),'YTick',[-1:0.2:1]) 
end 
ann=annotation('textbox', [0 0.9 1 0.1],'String','Position of particles','HorizontalAlignment','center','LineStyle','none'); 
drawnow