-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotSweepsOverlaid.m
55 lines (52 loc) · 1.71 KB
/
plotSweepsOverlaid.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[file, location] = uigetfile('.mat', 'Select One or More Files', 'MultiSelect', 'on');
if(iscell(file))
numFiles = length(file);
else
numFiles = 1;
file = {file};
end
%%
figure; hold on;
for i = 1:numFiles
clear channel1 channel2 lambdaArray
load(fullfile(location, file{i}), 'channel1', 'channel2', 'lambdaArray');
plot(lambdaArray, 10*log10(channel1), 'DisplayName', file{i});
end
hold off; legend();
xlabel("Wavelength (nm)"); ylabel("Transmission (dB)");
%% FFTs
figure;
for i = 1:numFiles
clear channel1 channel2 lambdaArray
load(fullfile(location, file{i}), 'channel1', 'channel2', 'lambdaArray');
thisTransmission = channel1; %./channel2;
thisTransNorm = thisTransmission; %/max(thisTransmission);
%thisTransNorm = 10*log10(thisTransmission/max(thisTransmission)); l
thisFFT = abs(fft(thisTransNorm)).^2;
thisDlambda = lambdaArray(2)-lambdaArray(1); % assumes uniform
N = length(thisFFT);
thisFreqAxis = (0:N-1)/(N*thisDlambda); thisMaxN = round(N/2);
loglog(thisFreqAxis(1:thisMaxN), thisFFT(1:thisMaxN), 'DisplayName', file{i});
if(i == 1)
hold on;
end
end
hold off; legend();
xlabel("Inverse wavelength units (nm^-1)"); ylabel("Power spectral density");
%% low pass filter
numAvg = 50;
h = [1/2 1/2];
binomialCoeff = conv(h,h);
for n = 1:numAvg
binomialCoeff = conv(binomialCoeff, h);
end
numFiles = length(file);
figure; hold on;
for i = 1:numFiles
clear channel1 channel2 lambdaArray
load(fullfile(location, file{i}), 'channel1', 'channel2', 'lambdaArray');
movingFilter = ones(1,numAvg)/numAvg;
filteredC1 = filter(binomialCoeff, 1, channel1);
plot(lambdaArray, 10*log10(filteredC1./channel2), 'DisplayName', file{i});
end
hold off