-
Notifications
You must be signed in to change notification settings - Fork 2
/
plotTransferFunctions_old.m
executable file
·89 lines (80 loc) · 2.26 KB
/
plotTransferFunctions_old.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function plotTransferFunctions_old
files = [dir([pwd '\transferFunctions\*clicks_*.csv']);dir([pwd '\transferFunctions\*click_*.mat']);dir([pwd '\transferFunctions\*.bin'])];
startTime=-1; %in ms
endTime=5; %in ms
monitorPosition = get(0,'monitorPositions');
monitorPosition = monitorPosition(1,:);
figure('position',monitorPosition);
h3 = subplot(6,3,[2 3 5 6]);
hold on
ylabel('Level (dB)');
title('Impulse');
h4 = subplot(6,3,[8 9 11 12]);
hold on
ylabel('Level (dB)');
title('Transfer function');
h5 = subplot(6,3,[14 15 17 18]);
hold on
xlabel('Frequency (kHz)');
ylabel('Level (dB)');
title('Impulse Response');
h1 = subplot(6,3,[1 4 7]);
hold on
ylabel('Amplitude (Volts)');
title('Impulse');
h2 = subplot(6,3,[10 13 16]);
hold on
xlabel('Time (ms)');
ylabel('Amplitude (Volts)');
title('Impulse Response');
count=0;
colors = 'bgrmk';
for iFile = 1:length(files)
[transfer,data] = loadTransferFunction_old([pwd '/transferFunctions/' files(iFile).name]);
if strfind(files(iFile).name,'HD')
style = '--';
else
style = '-';
end
k = strfind(files(iFile).name,'V');
if ~isempty(k) && ~isempty(str2num(files(iFile).name(k-1)))
switch(str2num(files(iFile).name(k-1)))
case 1
color = 'b';
case 2
color = 'g';
case 4
color = 'r';
case 5
color = 'm';
case 8
color = 'k';
count=count+1;
switch count
case 2
style = ':';
case 3
style = '-.';
end
end
else
color = colors(mod(iFile,length(colors))+1);
end
[~,legends{iFile}] = fileparts(files(iFile).name);
subplot(h3);
plot(transfer.frequencies,transfer.impulseFft,[style color]);
subplot(h4);
plot(transfer.frequencies,transfer.fft,[style color]);
subplot(h5);
plot(transfer.frequencies,transfer.impulseResponseFft,[style color]);
%plot relevant portion of impulse and impulse response
data(:,1) = data(:,1)*1000; %convert to ms
samplesToKeep = find(data(:,1)>startTime & data(:,1)<endTime);
subplot(h1);
plot(data(samplesToKeep,1),data(samplesToKeep,2),[style color])
subplot(h2);
plot(data(samplesToKeep,1),data(samplesToKeep,3),[style color])
end
subplot(h3);
legend(legends,'interpreter','none','location','southWest');
set(h3,'ylim',get(h5,'ylim'));