function [PMUindex,PMUAngleindex,PMUcurrentindex] = get_PMUindex(bus,line)
% Syntax:
% [PMUindex,PMUAngleindex,PMUcurrentindex] = get_measurementindex(bus,line)
% 
% Purpose:   To get PMU index for voltage and current measurement
%            
% Input:    bus           - bus data of system
%           line          - line data of system
%           
% Output:   PMUindex   - bus no where PMU voltage magnitude 
%                        measurements are available
%           PMUAngleindex - bus no where PMU voltage angle 
%                        measurements are available(exclude slack)
%           PMUcurrentindex  - line no where PMU current 
%                        measurements are available
%
% Calls:     
% Called by  
%

PMUindex=[];PMUAngleindex=[];PMUcurrentindex=[];

nob=length(bus(:,1)); %no. of bus
nol=length(line(:,1));  %no. of lines

% for i=1:nob
%     if bus(i,10)==1
%         slack=i;
%     end
% end

%index for voltage angle and magnitude
for i=1:nob    
    if bus(i,13)==1
        [PMUindex]=[PMUindex;i];
%         if i~=slack
%             [PMUAngleindex]=[PMUAngleindex;i];            
%         end                                  
    end
end
PMUAngleindex=PMUindex;

%index for line PMU currents
for i=1:length(PMUindex)
    for j=1:nol
        if line(j,1)==PMUindex(i)  %Start bus
            [PMUcurrentindex]=[PMUcurrentindex;j];%current from FROM_bus to TO_bus
        end
        if line(j,2)==PMUindex(i)  %End bus
            [PMUcurrentindex]=[PMUcurrentindex;j+nol];%current from TO_bus to FROM_bus
        end
    end
end
PMUcurrentindex=sort(PMUcurrentindex);
