function  [string,ls_index,p,plt_index]=plot_fig_cl(a,b,kp,ki,target,string,max_time,val,str,val2,volt_rpm)
     
    if(ishandle(2) == 0)
        temp=string{val};
        aa=figure(2);
        set(aa,'Position',get(0,'Screensize'));
        subplot(1,2,1);
        axis([0 max_time 0 4]);
        hold on;
        hline = refline([0 target]);
        set(hline,'Color','r');
        hold on;
        string={};
        ls_index=1;
        string{ls_index}=str;
        ls_index=ls_index+1;
        string{ls_index}=temp;
        ls_index=ls_index+1;
       
    else
        ls_index=val+1;
    end
        figure(2);
        subplot(1,2,1);
        stri='DC Speed Control Closed Loop Response Comparision';
        title(stri);
        yyaxis left
        xlabel('Time in seconds');
        ylabel('Tacho Output in Volts');
        axis([0 max_time 0 4]);
        hold on;
        b=[0 b];
        a=[a(1) a];
        p(val2)=plot(b,smooth(a),'color',rand(1,3));
        plt_index=val2+1;
        legend(string{:});
        yyaxis right
        axis([0 max_time 0 volt_rpm(4)]);
        ylabel('Motor response in RPM');
        grid on;
        grid minor;
        hold on;
        

        
end
