

s1 = serial('COM3','BaudRate',115200,'Parity','none','DataBits',8,'StopBits',1,'Terminator',{'CR/LF','LF'},'FlowControl','Hardware')
fopen(s1)

% To query the device.

fprintf(s1, '*IDN?')
[out]=fscanf(s1)

fprintf(s1, ':POWER?')
[out]=fscanf(s1)

fprintf(s1, ':WAVELENGTH?')
[out]=fscanf(s1')

%make a plot of power vs time
clear power t;
ii=1;
h=figure

tic
while ishandle(h)
    fprintf(s1, ':POWER?')
    [out]=fscanf(s1);
    power(ii)=str2double(out)*1000;
    t(ii)=toc;
    plot(t,power);
    xlabel('time (s)')
    ylabel('power (mW)')
    
    pause(.1)
    ii=ii+1;
end

fclose(s1)
