%Read measurement data from excel sheet
flag_return=0;
if flag_sim==1
    excelfilename='meas_data.xlsx';
else
    excelfilename= input('Enter the measurement xcel filename: ','s') ;
    if isempty(excelfilename)~=0
        fprintf('\t%s\n','EXCELFILENAME BLANK, ERROR');
        flag_return=1;
        return;
    end
    if exist(excelfilename,'file')~=2
        fprintf('\t%s\n','EXCELFILENAME does not exist, ERROR');
        flag_return=1;
        return
    end
end

temp=xlsread(excelfilename,'sys_param');
nob=temp(1);
nol=temp(2);
slack=temp(3);
clear temp;

line=xlsread(excelfilename,'linedata');
bus_shunt=xlsread(excelfilename,'bus_shunt');

[temp]=xlsread(excelfilename,'zero_inj');
z_Pinj=[];z_Qinj=[];
if ~isempty(temp)
    for i=1:length(temp)
        if temp(i,2)==1
            [z_Pinj]=[z_Pinj;temp(i,1)];
        end
        if temp(i,2)==2
            [z_Qinj]=[z_Qinj;temp(i,1)];
        end
    end
end
clear i temp;

[temp]=xlsread(excelfilename,'zero_flow');
z_Pflow=[];z_Qflow=[];
if ~isempty(temp)
    for i=1:length(temp(:,1))
        if line(temp(i,2),1)==temp(i,3) && line(temp(i,2),2)==temp(i,4)
            if temp(i,1)==1
                [z_Pflow]=[z_Pflow;temp(i,2)];
            elseif temp(i,1)==2
                [z_Qflow]=[z_Qflow;temp(i,2)];
            end
        elseif line(temp(i,2),1)==temp(i,4) && line(temp(i,2),2)==temp(i,3)
            if temp(i,1)==1
                [z_Pflow]=[z_Pflow;temp(i,2)+nol];
            elseif temp(i,1)==2
                [z_Qflow]=[z_Qflow;temp(i,2)+nol];
            end
        end
    end
end
clear i temp;

meas_bus=xlsread(excelfilename,'bus_meas');

meas_line=xlsread(excelfilename,'line_meas');

clear excelfilename;