Impl task1 some part of task2
This commit is contained in:
+75
-70
@@ -17,10 +17,10 @@ duration4 = length(trace4.iq) / sample_rate;
|
||||
|
||||
% 2.
|
||||
% get all four plot values
|
||||
[~,F1,T1,P1] = spectrogram(trace1.iq, window, overlap, fft_precision, sample_rate, "centered", "psd");
|
||||
[~,F2,T2,P2] = spectrogram(trace2.iq, window, overlap, fft_precision, sample_rate, "centered", "psd");
|
||||
[~,F3,T3,P3] = spectrogram(trace3.iq, window, overlap, fft_precision, sample_rate, "centered", "psd");
|
||||
[~,F4,T4,P4] = spectrogram(trace4.iq, window, overlap, fft_precision, sample_rate, "centered", "psd");
|
||||
[~,F1,T1,P1] = spectrogram(trace1.iq, window, overlap, fft_precision, sample_rate, "centered", "power");
|
||||
[~,F2,T2,P2] = spectrogram(trace2.iq, window, overlap, fft_precision, sample_rate, "centered", "power");
|
||||
[~,F3,T3,P3] = spectrogram(trace3.iq, window, overlap, fft_precision, sample_rate, "centered", "power");
|
||||
[~,F4,T4,P4] = spectrogram(trace4.iq, window, overlap, fft_precision, sample_rate, "centered", "power");
|
||||
|
||||
% begin calibrated color scale
|
||||
P1_dB = 10 * log10(P1);
|
||||
@@ -30,54 +30,57 @@ P4_dB = 10 * log10(P4);
|
||||
|
||||
all_P_dB = [P1_dB(:); P2_dB(:); P3_dB(:); P4_dB(:)];
|
||||
|
||||
p_dB_min = min(all_P_dB) - 20;
|
||||
p_dB_max = max(all_P_dB) + 20;
|
||||
% -50 to +50 so its like the example fig
|
||||
p_dB_min = min(all_P_dB) - 50;
|
||||
p_dB_max = max(all_P_dB) + 50;
|
||||
% end power calibrated color scale
|
||||
|
||||
% plot all figures like example shows
|
||||
figure(1);
|
||||
imagesc(T1, F1, P1_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 1");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(2);
|
||||
imagesc(T2, F2, P2_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 2");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(3);
|
||||
imagesc(T3, F3, P3_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 3");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(4);
|
||||
imagesc(T4, F4, P4_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 4");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
if ~calculations_only
|
||||
% plot all figures like example shows
|
||||
figure(1);
|
||||
imagesc(T1, F1, P1_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 1");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(2);
|
||||
imagesc(T2, F2, P2_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 2");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(3);
|
||||
imagesc(T3, F3, P3_dB);
|
||||
axis ij;
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 3");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]);
|
||||
|
||||
figure(4);
|
||||
imagesc(T4, F4, P4_dB);
|
||||
axis ij; % flip so its like the example fig
|
||||
xlabel("Time [s]");
|
||||
ylabel("Freq. [Hz]");
|
||||
title("Spectrogram Trace 4");
|
||||
cb = colorbar;
|
||||
ylabel(cb, "Power [dB]");
|
||||
clim([p_dB_min p_dB_max]);
|
||||
xlim([0 0.05]); % reduce view so its like the example fig
|
||||
end
|
||||
|
||||
% 3.
|
||||
noise_floor1 = prctile(P1_dB(:), 10);
|
||||
@@ -99,28 +102,30 @@ channels = [1 5 9 13];
|
||||
[occupancy_max, max_idx] = max(occupancies);
|
||||
busiest_channel = channels(max_idx);
|
||||
|
||||
disp("Results:" + newline)
|
||||
if ~calculations_only
|
||||
disp("Results Task 1:" + newline)
|
||||
|
||||
disp("-- Trace duration ---")
|
||||
disp("Channel 1 duration: " + duration1 + "s")
|
||||
disp("Channel 5 duration: " + duration2 + "s")
|
||||
disp("Channel 9 duration: " + duration3 + "s")
|
||||
disp("Channel 13 duration: " + duration4 + "s" + newline)
|
||||
disp("-- Trace duration ---")
|
||||
disp("Channel 1 duration: " + duration1 + "s")
|
||||
disp("Channel 5 duration: " + duration2 + "s")
|
||||
disp("Channel 9 duration: " + duration3 + "s")
|
||||
disp("Channel 13 duration: " + duration4 + "s" + newline)
|
||||
|
||||
disp("--- Noise floor ---")
|
||||
disp("Distinct:")
|
||||
disp("Channel 1 noise floor: " + noise_floor1 + "dB")
|
||||
disp("Channel 5 noise floor: " + noise_floor2 + "dB")
|
||||
disp("Channel 9 noise floor: " + noise_floor3 + "dB")
|
||||
disp("Channel 13 noise floor: " + noise_floor4 + "dB" + newline)
|
||||
disp("--- Noise floor ---")
|
||||
disp("Distinct:")
|
||||
disp("Channel 1 noise floor: " + noise_floor1 + "dB")
|
||||
disp("Channel 5 noise floor: " + noise_floor2 + "dB")
|
||||
disp("Channel 9 noise floor: " + noise_floor3 + "dB")
|
||||
disp("Channel 13 noise floor: " + noise_floor4 + "dB" + newline)
|
||||
|
||||
disp("Combined:")
|
||||
disp("Channel all noise floor: " + noise_floor_avg + "dB" + newline)
|
||||
disp("Combined:")
|
||||
disp("Channel all noise floor: " + noise_floor_avg + "dB" + newline)
|
||||
|
||||
disp("-- Occupancy ---")
|
||||
disp("Channel 1 occupancy: " + occupancy1)
|
||||
disp("Channel 5 occupancy: " + occupancy2)
|
||||
disp("Channel 9 occupancy: " + occupancy3)
|
||||
disp("Channel 13 occupancy: " + occupancy4 + newline)
|
||||
disp("-- Occupancy ---")
|
||||
disp("Channel 1 occupancy: " + occupancy1 + "%")
|
||||
disp("Channel 5 occupancy: " + occupancy2 + "%")
|
||||
disp("Channel 9 occupancy: " + occupancy3 + "%")
|
||||
disp("Channel 13 occupancy: " + occupancy4 + "%" + newline)
|
||||
|
||||
disp("Busiest channel: " + busiest_channel)
|
||||
disp("Busiest channel: " + busiest_channel)
|
||||
end
|
||||
Reference in New Issue
Block a user