function [J_VM,J_VA,err_VM,err_VA] = form_J_PMUV(VV,m_VMA,nob,slack)
% Syntax:   [J_VM,J_VA,err_VM,err_VA] = form_J_PMUV(VV,m_VMA,nob,slack)
% 
% Purpose:   To form the measurement jacobian as well as error corresponding
%            to PMU voltage phasor measurement in polar form wrt. VA & VM
%            
% Input:    VV     - Voltage vector in complex form
%           m_VMA  - PMU voltage meas. information (col1: meas_index
%                    col2:V_abs_meas col3:V_ang_meas col4:R_abs col5:R_ang
%           nob    - number of buses
%           slack  - slack bus number
%                      
% Output:   J_VM   - Jacobian corresponding to PMU Voltage magnitude 
%           J_VA   - Jacobian corresponding to PMU Voltage angle in radian
%           err_VM - error corresponding to PMU Voltage magnitude
%           err_VA - error corresponding to PMU Voltage angle in radian
%
%
err_VM=[];err_VA=[];J_VM=[];J_VA=[];
if isempty(m_VMA)==0
    for i=1:length(m_VMA(:,1))
        k=m_VMA(i,1);
        [err_VM]=[err_VM;m_VMA(i,2)-abs(VV(k))];
        temp=zeros(1,2*nob);temp(1,nob+k)=1;
        [J_VM]=[J_VM;temp];
        if k~=slack
            [err_VA]=[err_VA;m_VMA(i,3)-angle(VV(k))];
            temp=zeros(1,2*nob);temp(1,k)=1;
            [J_VA]=[J_VA;temp];
        end
    end
end