% Set current, return voltage
% function [voltage] = keithley_set_current(address,current)
function [voltage] = func_keithley_set_current(address,current)

current = current./1000;
fprintf(address,':SOUR:FUNC CURR'); %Select current source.
fprintf(address,':SENS:VOLT:RANG:AUTO ON');%auto measure range.
fprintf(address,':SENS:FUNC "VOLT"'); %Voltage measure function.
fprintf(address,':FORM:ELEM VOLT');  %Voltage reading only.
fprintf(address,':OUTP ON');       %Output on    
command = [':SOUR:CURR:LEV ' num2str(current)];
fprintf(address,command);
pause(0.1);
fprintf(address,':READ?');                 %Trigger, acquire reading
voltage = scanstr(address,',','%f');