function [true_bus,true_line]=get_meas_true(bus_sol,line_flow,nob,nol)
%Find all the true value of measurement quantity from load flow solution
%
%INPUT :  bus_sol  |  line_flow | nob | nol
%
%OUTPUT:  true_bus  &  true_line
%         true_bus -->> meas_value, meas_type and meas_location in column
%         meas_type:  PINJECTION->1 , QINJECTION->2 , VABS->3 , VANG_RAD->4
%==========================================================================
%         true_line -->> meas_value, meas_type ,  LINE_NO , meas_FROMBUS
%         and meas_TOBUS in column
%         meas_type:  PFLOW->1 , QFLOW->2 , IABS->3 , IANG_RAD->4 ,
%         meas_type:  IREAL->5 , IIMAG->6
%==========================================================================

true_bus=[bus_sol(:,4)-bus_sol(:,6) ones(nob,1) bus_sol(:,1)];
[true_bus]=[true_bus; bus_sol(:,5)-bus_sol(:,7) 2*ones(nob,1) bus_sol(:,1)];
[true_bus]=[true_bus;bus_sol(:,2) 3*ones(nob,1) bus_sol(:,1)];
[true_bus]=[true_bus;bus_sol(:,3)*pi/180 4*ones(nob,1) bus_sol(:,1)];

V=bus_sol(:,2);%Voltage magnitude
VAng=bus_sol(:,3)*pi/180;%Voltage angle in radian
VV = V.*exp(1i*VAng);  % solution voltage in complex form
Pflow=line_flow(:,4);
Qflow=line_flow(:,5);
temp=zeros(2*nol,5);
for i=1:2*nol
    m=line_flow(i,2);%from bus
    temp(i,1)=i;
    temp(i,2)=abs(conj((Pflow(i)+1i*Qflow(i))/VV(m)));
    temp(i,3)=angle(conj((Pflow(i)+1i*Qflow(i))/VV(m))); 
    temp(i,4)=real(conj((Pflow(i)+1i*Qflow(i))/VV(m)));
    temp(i,5)=imag(conj((Pflow(i)+1i*Qflow(i))/VV(m)));    
end

true_line=[line_flow(:,4) ones(2*nol,1) line_flow(:,1:3)];
[true_line]=[true_line;line_flow(:,5) 2*ones(2*nol,1) line_flow(:,1:3)];
[true_line]=[true_line;temp(:,2) 3*ones(2*nol,1) line_flow(:,1:3)];
[true_line]=[true_line;temp(:,3) 4*ones(2*nol,1) line_flow(:,1:3)];
[true_line]=[true_line;temp(:,4) 5*ones(2*nol,1) line_flow(:,1:3)];
[true_line]=[true_line;temp(:,5) 6*ones(2*nol,1) line_flow(:,1:3)];

