clear all;
clc;
clf;

osa=gpib('ni',0,23);
osa.InputBufferSize=10000;
osa.Timeout=120;
fopen(osa);

wstart=1500;
wstop=1600;
wspan=100;
n_scan=floor((wstop-wstart)/wspan);

db_div=10;
ref_lvl=-10;
y_bot=ref_lvl - (10*db_div);

fprintf(osa,'TS');
fprintf(osa,'CENTERWL 1550NM;SP 250NM;SENS -80DBM;RL -10DBM;RB 10NM;LG 10');
fprintf(osa,'TRA?')
out = str2num(fscanf(osa));
fprintf(osa,'TS');
fclose(osa);
delete(osa);
clear osa;
w_increment=wspan*n_scan/(max(size((out)))-1);
wavelength=wstart:w_increment:(wstart+wspan*n_scan);
figure(1);
plot(wavelength,out);
ylim([y_bot ref_lvl]);