From 4159a3a5cbd9a2a8fedb27dc290cf7ee9a29a095 Mon Sep 17 00:00:00 2001 From: Kevin D Date: Sun, 3 May 2026 09:23:21 -0700 Subject: [PATCH] coordinate bug cleanup --- @rfSensor/clearRssCache.m | 11 +++++++++++ @rfSensor/rfSensor.m | 1 + @rfSensor/transmitterGain.m | 2 +- test/test_rfSensor.m | 10 +++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 @rfSensor/clearRssCache.m diff --git a/@rfSensor/clearRssCache.m b/@rfSensor/clearRssCache.m new file mode 100644 index 0000000..29a772b --- /dev/null +++ b/@rfSensor/clearRssCache.m @@ -0,0 +1,11 @@ +function obj = clearRssCache(obj) + arguments (Input) + obj (1, 1) {mustBeA(obj, "rfSensor")}; + end + arguments (Output) + obj (1, 1) {mustBeA(obj, "rfSensor")}; + end + + obj.rssCache = double.empty(0, 1); + +end \ No newline at end of file diff --git a/@rfSensor/rfSensor.m b/@rfSensor/rfSensor.m index 8b125c0..9f1a271 100644 --- a/@rfSensor/rfSensor.m +++ b/@rfSensor/rfSensor.m @@ -24,6 +24,7 @@ classdef rfSensor [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 + obj = clearRssCache(obj); end methods (Access = private) x = RSS(obj, d, t, a); % Received signal strength (function of distance and tilt angle) diff --git a/@rfSensor/transmitterGain.m b/@rfSensor/transmitterGain.m index 35c3c58..c85941b 100644 --- a/@rfSensor/transmitterGain.m +++ b/@rfSensor/transmitterGain.m @@ -15,7 +15,7 @@ function value = transmitterGain(obj, t, a) % Angular offset from boresight via spherical law of cosines % Convention: t=0° nadir, t=90° horizon; a=0° +y, a=90° +x - cos_theta = sind(obj.tilt) .* sind(t) .* cosd(a - obj.tilt) + ... + cos_theta = sind(obj.tilt) .* sind(t) .* cosd(a - obj.azimuth) + ... cosd(obj.tilt) .* cosd(t); cos_theta = max(-1, min(1, cos_theta)); % clamp for numerical safety theta = acosd(cos_theta); diff --git a/test/test_rfSensor.m b/test/test_rfSensor.m index 3a9e4c8..3bf6b84 100644 --- a/test/test_rfSensor.m +++ b/test/test_rfSensor.m @@ -30,10 +30,18 @@ classdef test_rfSensor < matlab.unittest.TestCase 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, 0, 0); + tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi, 30, 135); altitude = 30; + % Boresight azimuth=135° (between +X at 90° and -Y at 180°) → hotspot at +X,-Y. + % SNR at (5,-5) should be higher than at (5,+5). + agentPos = [0, 0, altitude]; + [~, snrA] = tc.testClass.sensorPerformance(agentPos, [5, -5, 0]); + % tc.testClass = tc.testClass.clearRssCache(); + [~, snrB] = tc.testClass.sensorPerformance(agentPos, [5, 5, 0]); + tc.assertGreaterThan(snrA, snrB, "SNR should be higher toward boresight (+X,-Y) than away from it (+X,+Y)"); + tc.testClass.plotPerformance(altitude); end function plot_SINR_one_interferer(tc)