Aufgrund einer Wartung wird GitLab am 18.01. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 18.01. between 8:00 and 9:00 am.

ppa_run_analysis.m 2.83 KB
Newer Older
henryjandrew's avatar
henryjandrew committed
1
%% Input conditions
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
2
3
4
%target_path = 'path_19a0a7019da43b074b372bcbdf6adb25'; %path to follow through simulation
target_path = 'path_50df740f16865a987b4b69ff1bb12c2f';
%target_path = 'diffracted_path';
henryjandrew's avatar
henryjandrew committed
5
plot_single_path_freq = true;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
6
7
plot_all_delay_changes = false;
plot_all_gain_changes = false;
henryjandrew's avatar
henryjandrew committed
8
%load('example_ppa_output_data.mat','-mat');
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
9
%load('example_outdoor_acoustics_output_data','-mat');
henryjandrew's avatar
henryjandrew committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

%% Initial set up
N_frames = size( run_data, 2 );
N_paths = numel(all_path_names);

if plot_single_path_freq
    freq_evolution = zeros(N_frames,31);
    valid_evolution = zeros(N_frames,31);
end
if plot_all_delay_changes
    delay_changes = zeros(N_frames, N_paths);
    prev_delay = zeros(1,N_paths);
end
if plot_all_gain_changes
    gain_changes = zeros(N_frames, N_paths);
    prev_gain = zeros(1,N_paths);
end
f = ita_ANSI_center_frequencies;

%% Main loop
for n = 1:N_frames %loop over all frames
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
31
    %tic
henryjandrew's avatar
henryjandrew committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    if plot_single_path_freq
        try
            path = run_data{1,n}.(target_path);
            freq_evolution(n,:) = path.frequency_magnitudes;
            valid_evolution(n,:) = path.audible;
        catch
            freq_evolution(n,:) = zeros(1,31);
            valid_evolution(n,:) = zeros(1,31);
        end
    end
    if plot_all_delay_changes || plot_all_gain_changes
        for p = 1:N_paths
            try
                path = run_data{1,n}.(all_path_names{p});
                delay_changes(n,p) = path.delay - prev_delay(p);
                prev_delay(p) = path.delay;
                
                gain_changes(n,p) = path.gain - prev_gain(p);
                prev_gain(p) = path.gain;
            catch
            end

        end
    end
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
56
57
    
    %fprintf( 'Took %.2f seconds for fram %i%/i%\n', toc, n, N_frames )
henryjandrew's avatar
henryjandrew committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
end

%% Plot Graphs
if plot_single_path_freq
    single_path_freq_evolution( f, N_frames, freq_evolution, valid_evolution );
end
if plot_all_delay_changes
    all_path_delay_changes( delay_changes(2:end,:), N_paths, N_frames-1 );
end
if plot_all_gain_changes
    all_path_gain_changes( gain_changes(2:end,:), N_paths, N_frames-1 );
end


%% Plot functions
function single_path_freq_evolution( f, N, freq_evolution, valid_evolution )
    [X,Y] = meshgrid(f, 1:N);
    figure
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
76
77
    s1 = surf( X, Y, freq_evolution, valid_evolution );
    set( s1, 'EdgeAlpha', 0.05 );
henryjandrew's avatar
henryjandrew committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    xlabel('Frequency (KHz)')
    ylabel('Frame number')
    zlabel('Frequency Magnitudes')
    grid off
end

function all_path_delay_changes( delay_changes, N_paths, N_frames )
    [X,Y] = meshgrid(1:N_paths, 1:N_frames);
    figure
    surf( X, Y, delay_changes)
    xlabel('Frames')
    ylabel('Paths')
    zlabel('Delay Change')
    grid off
end

function all_path_gain_changes( gain_changes, N_paths, N_frames )
    [X,Y] = meshgrid(1:N_paths, 1:N_frames);
    figure
    surf( X, Y, gain_changes)
    xlabel('Frames')
    ylabel('Paths')
    zlabel('Gain Change')
    grid off
end