From e19e9870d7f7d0bd5b49a86ffcbd8728c3468a7b Mon Sep 17 00:00:00 2001 From: Kevin D Date: Sun, 26 Apr 2026 11:46:25 -0700 Subject: [PATCH] added SNR and SINR footprint images --- @rfSensor/pathLoss.m | 4 ++-- @rfSensor/plotPerformance.m | 29 ++++++++++++++++++----------- test/test_rfSensor.m | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/@rfSensor/pathLoss.m b/@rfSensor/pathLoss.m index 08198d0..c638699 100644 --- a/@rfSensor/pathLoss.m +++ b/@rfSensor/pathLoss.m @@ -7,7 +7,7 @@ function L_FSPL_dB = pathLoss(obj, d) L_FSPL_dB (:, 1) double end - % Free Space Path Loss (dB) - L_FSPL_dB = 20*log10(d) + 20*log10(obj.f_c) + 20*log10((4*pi)/obj.c); + % Free Space Path Loss (dB); d clamped away from zero (log undefined at d=0) + L_FSPL_dB = 20*log10(max(d, eps)) + 20*log10(obj.f_c) + 20*log10((4*pi)/obj.c); end diff --git a/@rfSensor/plotPerformance.m b/@rfSensor/plotPerformance.m index d5cc38c..f44b77b 100644 --- a/@rfSensor/plotPerformance.m +++ b/@rfSensor/plotPerformance.m @@ -9,6 +9,8 @@ function f = plotPerformance(obj, altitude, otherSensorsPos, otherSensors) f (1, 1) {mustBeA(f, "matlab.ui.Figure")}; end + otherSensorsPos = otherSensorsPos + [0, 0, altitude]; + % Create grid on which to evalute SINR, SNR agentPos = [0, 0, altitude]; d = max(10, max(vecnorm(otherSensorsPos(1:2), 2, 2)) * 1.25); @@ -22,20 +24,25 @@ function f = plotPerformance(obj, altitude, otherSensorsPos, otherSensors) SINR = reshape(SINR, size(targetPosX)); SNR = reshape(SNR, size(targetPosX)); - % normalize - SINR = SINR ./ max(SINR); - SNR = SNR ./ max(SNR); + % normalize in linear scale + SINR = 10.^(SINR/10); SINR = SINR ./ max(SINR(:)); SINR = 10 * log10(SINR); + SNR = 10.^(SNR/10); SNR = SNR ./ max(SNR(:)); SNR = 10 * log10(SNR); f = figure; - imagesc(SNR); - axis("image"); - colorbar; - title("Normalized SNR"); + tiledlayout(1, 2, TileSpacing="compact", Padding="compact"); - f = figure; - imagesc(SINR); - axis("image"); + nexttile; + imagesc(distances, distances, SNR); + axis("image"); set(gca, 'YDir', 'normal'); colorbar; - title("Normalized SINR"); + xlabel("X (m)"); ylabel("Y (m)"); + title("Linearly Normalized SNR (dB)"); + + nexttile; + imagesc(distances, distances, SINR); + axis("image"); set(gca, 'YDir', 'normal'); + colorbar; + xlabel("X (m)"); ylabel("Y (m)"); + title("Linearly Normalized SINR (dB)"); end \ No newline at end of file diff --git a/test/test_rfSensor.m b/test/test_rfSensor.m index 5f92eb3..ac2e76c 100644 --- a/test/test_rfSensor.m +++ b/test/test_rfSensor.m @@ -46,7 +46,7 @@ classdef test_rfSensor < matlab.unittest.TestCase tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi); altitude = 30; - otherSensorsPos = [5, 0, 400]; % relative to main sensor + otherSensorsPos = [6, -4, -1]; % relative to main sensor otherSensors = cell(1, 1); otherSensors{1} = tc.testClass; % 2 identical sensors