seems finished
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
function result = analyzeTrace(trace_file, channel, window, overlap, fft_precision, sample_rate)
|
||||
trace = load(trace_file, "iq");
|
||||
|
||||
% 1
|
||||
duration = length(trace.iq) / sample_rate;
|
||||
|
||||
% 2
|
||||
[S, F, T] = spectrogram(trace.iq, window, overlap, fft_precision, sample_rate, "centered");
|
||||
|
||||
% 3
|
||||
mag = abs(S).^2;
|
||||
P_dB = linearTodB(mag);
|
||||
|
||||
% Sum all frequency bins per time slot to obtain total channel power.
|
||||
channel_power_linear = sum(mag, 1);
|
||||
channel_power_dB = linearTodB(channel_power_linear);
|
||||
|
||||
noise_floor_linear = prctile(channel_power_linear, 10);
|
||||
noise_floor = linearTodB(noise_floor_linear);
|
||||
|
||||
% 4
|
||||
occupancy = sum(channel_power_dB > noise_floor + 10) / numel(channel_power_dB) * 100;
|
||||
|
||||
result.trace_file = trace_file;
|
||||
result.iq = trace.iq;
|
||||
result.channel = channel;
|
||||
result.duration = duration;
|
||||
|
||||
result.S = S;
|
||||
result.F = F;
|
||||
result.T = T;
|
||||
|
||||
result.mag = mag;
|
||||
result.P_dB = P_dB;
|
||||
|
||||
result.channel_power_linear = channel_power_linear;
|
||||
result.channel_power_dB = channel_power_dB;
|
||||
|
||||
result.noise_floor_linear = noise_floor_linear;
|
||||
result.noise_floor = noise_floor;
|
||||
|
||||
result.occupancy = occupancy;
|
||||
end
|
||||
Reference in New Issue
Block a user