function [all_bus,all_line]=get_meas_total(true_bus,true_line,err_spec,flag_err,nob,nol)

%Generate all possible measurement
%all_bus has the same format as true_bus
%all_line has the same format as true_line
%
%flag_err==1 i.e. err_spec=[Inj flow PMU_abs PMU_angle_radian] in S.D.
%flag_err==2 i.e. err_spec=[inj flow Vabs Iabs PMU_angle_degree] in max 
%meas uncertainty in %

if flag_err==2
    %UNIFORM ERROR DISTRIBUTION
    all_bus=[];
    my_rand=rand(4*nob,1);
    for i=1:4*nob
        if true_bus(i,2)==1 || true_bus(i,2)==2
            temp=true_bus(i,1)*(1+(-1+2*my_rand(i))*err_spec(1)/100);
            [temp]=[temp true_bus(i,2:3)];
            [all_bus]=[all_bus;temp];clear temp;
        elseif true_bus(i,2)==3
            temp=true_bus(i,1)*(1+(-1+2*my_rand(i))*err_spec(3)/100);
            [temp]=[temp true_bus(i,2:3)];
            [all_bus]=[all_bus;temp];clear temp;
        elseif true_bus(i,2)==4
            temp=true_bus(i,1)+(-1+2*my_rand(i))*err_spec(5)*pi/180;
            [temp]=[temp true_bus(i,2:3)];
            [all_bus]=[all_bus;temp];clear temp;
        end
    end
    clear my_rand;
    
    all_line=[];
    my_rand=rand(12*nol,1);
    for i=1:12*nol
        if true_line(i,2)==1 || true_line(i,2)==2
            temp=true_line(i,1)*(1+(-1+2*my_rand(i))*err_spec(2)/100);
            [temp]=[temp true_line(i,2:5)];
            [all_line]=[all_line;temp];clear temp;
        elseif true_line(i,2)==3
            temp=true_line(i,1)*(1+(-1+2*my_rand(i))*err_spec(4)/100);
            [temp]=[temp true_line(i,2:5)];
            [all_line]=[all_line;temp];clear temp;
        elseif true_line(i,2)==4
            temp=true_line(i,1)+(-1+2*my_rand(i))*err_spec(5)*pi/180;
            [temp]=[temp true_line(i,2:5)];
            [all_line]=[all_line;temp];clear temp;
        elseif true_line(i,2)==5 || true_line(i,2)==6
            temp=true_line(i,1)*(1+(-1+2*my_rand(i))*err_spec(4)/100);
            [temp]=[temp true_line(i,2:5)];
            [all_line]=[all_line;temp];clear temp;
        end
    end
else
    %GAUSSIAN ERROR DISTRIBUTION
    temp=[normrnd(0,err_spec(1),2*nob,1); normrnd(0,err_spec(3),nob,1)];
    [temp]=[temp;normrnd(0,err_spec(4),nob,1)];
    all_bus=[true_bus(:,1)+temp true_bus(:,2:3)];
    
    temp=[normrnd(0,err_spec(2),4*nol,1); normrnd(0,err_spec(3),2*nol,1)];
    [temp]=[temp;normrnd(0,err_spec(4),2*nol,1);normrnd(0,err_spec(3),4*nol,1)];
    all_line=[true_line(:,1)+temp true_line(:,2:5)];
end

