From 5cbb3956840a06856b40fc17244db67a1590adc3 Mon Sep 17 00:00:00 2001 From: Kevin D Date: Sun, 26 Apr 2026 10:59:30 -0700 Subject: [PATCH] added SINR visualization --- @rfSensor/plotPerformance.m | 41 +++++++++++++++++++++++++++++++++++ @rfSensor/rfSensor.m | 5 +++-- @rfSensor/sensorPerformance.m | 6 +++-- test/test_rfSensor.m | 32 ++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 @rfSensor/plotPerformance.m diff --git a/@rfSensor/plotPerformance.m b/@rfSensor/plotPerformance.m new file mode 100644 index 0000000..d5cc38c --- /dev/null +++ b/@rfSensor/plotPerformance.m @@ -0,0 +1,41 @@ +function f = plotPerformance(obj, altitude, otherSensorsPos, otherSensors) + arguments (Input) + obj (1, 1) {mustBeA(obj, "rfSensor")}; + altitude (1, 1) double; + otherSensorsPos (:, 3) double = NaN(0, 3); + otherSensors (:, 1) cell = cell(0, 1); + end + arguments (Output) + f (1, 1) {mustBeA(f, "matlab.ui.Figure")}; + end + + % Create grid on which to evalute SINR, SNR + agentPos = [0, 0, altitude]; + d = max(10, max(vecnorm(otherSensorsPos(1:2), 2, 2)) * 1.25); + c = 0.1; + d = ceil(d / c) * c; + distances = -d:c:d; + [targetPosX, targetPosY] = meshgrid(distances, distances); + + % Compute SINR, SNR + [SINR, SNR] = obj.sensorPerformance(agentPos, [targetPosX(:), targetPosY(:), zeros(size(targetPosX(:)))], otherSensorsPos, otherSensors); + SINR = reshape(SINR, size(targetPosX)); + SNR = reshape(SNR, size(targetPosX)); + + % normalize + SINR = SINR ./ max(SINR); + SNR = SNR ./ max(SNR); + + f = figure; + imagesc(SNR); + axis("image"); + colorbar; + title("Normalized SNR"); + + f = figure; + imagesc(SINR); + axis("image"); + colorbar; + title("Normalized SINR"); + +end \ No newline at end of file diff --git a/@rfSensor/rfSensor.m b/@rfSensor/rfSensor.m index 14381e2..20ac328 100644 --- a/@rfSensor/rfSensor.m +++ b/@rfSensor/rfSensor.m @@ -16,9 +16,10 @@ classdef rfSensor methods (Access = public) [obj] = initialize(obj, txPower, bandwidth, centerFreq, rxGain); % initialize sensor, define parameters - [SINR] = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors); % determine sensor performance for a given single sensor and target geometry - [f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle + [SINR, SNR] = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors); % determine sensor performance for a given single sensor and target geometry [d, t, a] = computePointToPoints(obj, agentPos, targetPos); + [f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle + [f] = plotPerformance(obj, altitude, otherSensorsPos, otherSensors); % debug, plot SNR or SINR ground heatmap for a given geometry end methods (Access = private) x = RSS(obj, d, t, a); % Received signal strength (function of distance and tilt angle) diff --git a/@rfSensor/sensorPerformance.m b/@rfSensor/sensorPerformance.m index 9e35fff..53f83e2 100644 --- a/@rfSensor/sensorPerformance.m +++ b/@rfSensor/sensorPerformance.m @@ -1,4 +1,4 @@ -function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors) +function [SINR, SNR] = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors) arguments (Input) obj (1, 1) {mustBeA(obj, "rfSensor")}; agentPos (1, 3) double; @@ -8,6 +8,7 @@ function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, oth end arguments (Output) SINR (:, 1) double; + SNR (:, 1) double; end assert(size(otherSensorsPos, 1) == size(otherSensors, 1), "Mismatch in number of other sensor positions (%d) and number of other sensors (%d) provided", size(otherSensorsPos, 1), size(otherSensors, 1)); @@ -16,10 +17,11 @@ function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, oth % Performance is measured as SINR for this sensor S = 10 .^ (0.1 .* obj.RSS(d, t, a)); % Signal I = zeros(size(d)); % Interference from other agents - for ii = 1:size(otherSensors, 2) + for ii = 1:size(otherSensors, 1) [d_other, t_other, a_other] = otherSensors{ii}.computePointToPoints(otherSensorsPos(ii, 1:3), targetPos); I = I + 10 .^ (0.1 .* otherSensors{ii}.RSS(d_other, t_other, a_other)); end SINR = 10*log10(S ./ (I + obj.N)); + SNR = 10*log10(S ./ obj.N); end \ No newline at end of file diff --git a/test/test_rfSensor.m b/test/test_rfSensor.m index 2cafc6f..5f92eb3 100644 --- a/test/test_rfSensor.m +++ b/test/test_rfSensor.m @@ -12,7 +12,7 @@ classdef test_rfSensor < matlab.unittest.TestCase end methods (Test) - function plot_SNR(tc) + function plot_RSS(tc) % Plot sensor performance with no sources of interference P_TX = 1e-3; % Transmit power (Watts) BW = 20e6; % Bandwidth (Hz) @@ -23,5 +23,35 @@ classdef test_rfSensor < matlab.unittest.TestCase tc.testClass.plotParameters(); end + function plot_SNR(tc) + % Plot sensor performance with no sources of interference + P_TX = 1e-3; % Transmit power (Watts) + BW = 20e6; % Bandwidth (Hz) + f_c = 2e9; % Center frequency (Hz) + G_RX_dBi = 3; % Receiving Antenna Gain (dBi) + + tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi); + + altitude = 30; + + tc.testClass.plotPerformance(altitude); + end + function plot_SINR_one_interferer(tc) + % Plot sensor performance with no sources of interference + P_TX = 1e-3; % Transmit power (Watts) + BW = 20e6; % Bandwidth (Hz) + f_c = 2e9; % Center frequency (Hz) + G_RX_dBi = 3; % Receiving Antenna Gain (dBi) + + tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi); + + altitude = 30; + otherSensorsPos = [5, 0, 400]; % relative to main sensor + otherSensors = cell(1, 1); + otherSensors{1} = tc.testClass; % 2 identical sensors + + tc.testClass.plotPerformance(altitude, otherSensorsPos, otherSensors); + + end end end \ No newline at end of file