function [Vout] = LabInst_VvsV(lab_bench_nr,V,gpp_channel, current_limit)
% function [Vout] = LabInst_VvsV(lab_bench_nr,V,gpp_channel, current_limit)
%  sources V on gpp channel 'gpp_channel' and measures V on gdm on lab
%  bench number 'lab_bench_nr'.
% V can be a vector in which case a sweep is performed and Vout will be the
% corresponding vector of output values. Be sure to connect the voltage
% measurement ports on gdm! current_limit needs to be sufficiently high to
% allow V to be sourced.
% Author: Philipp Häfliger, 4-Feb-2025


hgpp=LabInst_GetHandle("gpp",lab_bench_nr)
hgdm=LabInst_GetHandle("gdm",lab_bench_nr)

I=zeros(1,length(V));
for s=1:length(V)
    GPP_SetVoltage(hgpp,gpp_channel,V(s),current_limit)
    pause(2);
    Vout(s)=GDM_GetVoltage(hgdm);
end; %for

LabInst_CloseHandle(hgpp);
LabInst_CloseHandle(hgdm);

plot(V,Vout)

end