function phv = plot3D_rph2_hv_w2_a(a,b,w2,tau)
% Compute the Variability Index versu w2 and tau
% w2 and a are row vectors

n = length(a);

w1 = 1 - w2;

for i=1:1:n
l = (a(i)*b) ./ (a(i)*w2 + b.*w1);
C2x = 2*(l.*l).*(((a(i)*a(i))*w2 + (b*b).*w1)./(a(i)*a(i)*b*b)) - 1;
A = (2*l.*((a(i)*w1+b*w2).^2 - (a(i)*a(i)*w1 + b*b*w2)))./(a(i)*w2 + b*w1).^3;
vn = A.*(1-exp(-1*(a(i)*w2+b*w1)*tau)) + l.*C2x*tau;
dvn = A.*(a(i)*w2+b*w1).*exp(-1*(a(i)*w2+b*w1)*tau) + l.*C2x;

hv(:,i) = (0.5 * tau) * (dvn ./ vn)';
end

hv;

mesh(a, w2, hv);
xlabel('a','FontSize',14);
ylabel('w2','FontSize',14);
zlabel('H_v','FontSize',14);
