From 275123d0fc31712831574c7ce1efc53304add2a5 Mon Sep 17 00:00:00 2001 From: Kevin D Date: Tue, 21 Apr 2026 09:14:38 -0700 Subject: [PATCH] cleanup before refactoring --- @rfSensor/antennaGain.m | 3 ++- @rfSensor/initialize.m | 9 ++++++++- @rfSensor/plotParameters.m | 1 + @rfSensor/rfSensor.m | 8 ++++---- test/test_rfSensor.m | 22 ++++++++++++++++------ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/@rfSensor/antennaGain.m b/@rfSensor/antennaGain.m index 7fb9f3a..4fdd4e7 100644 --- a/@rfSensor/antennaGain.m +++ b/@rfSensor/antennaGain.m @@ -8,5 +8,6 @@ function value = antennaGain(obj, t) end % TODO - value = 10*log10(1); + % Temporary logic to make nadir-pointing most effective + value = 10*log10(cosd(t)); end diff --git a/@rfSensor/initialize.m b/@rfSensor/initialize.m index dececa7..20c3f87 100644 --- a/@rfSensor/initialize.m +++ b/@rfSensor/initialize.m @@ -1,9 +1,16 @@ -function obj = initialize(obj) +function obj = initialize(obj, txPower, bandwidth, centerFreq) arguments (Input) obj (1, 1) {mustBeA(obj, "rfSensor")} + txPower (1, 1) double; + bandwidth (1, 1) double; + centerFreq (1, 1) double; end arguments (Output) obj (1, 1) {mustBeA(obj, "rfSensor")} end + + obj.P_TX = txPower; + obj.BW = bandwidth; + obj.f_c = centerFreq; end \ No newline at end of file diff --git a/@rfSensor/plotParameters.m b/@rfSensor/plotParameters.m index 4fa481b..1a39138 100644 --- a/@rfSensor/plotParameters.m +++ b/@rfSensor/plotParameters.m @@ -9,6 +9,7 @@ function f = plotParameters(obj) % Distance and tilt sample points d = [0.01, 0.1, 0.25, 0.5, 0.75, 1:1:100]; t = zeros(size(d)); + t = -90:1:90; % Sample RSS function by distances, tilts r_x = obj.RSS(d', t'); diff --git a/@rfSensor/rfSensor.m b/@rfSensor/rfSensor.m index 4f9c454..9759fd0 100644 --- a/@rfSensor/rfSensor.m +++ b/@rfSensor/rfSensor.m @@ -5,13 +5,13 @@ classdef rfSensor k_B = 1.38e-23 % Boltzmann constant (W/Hz/K) for thermal noise model T_0 = 300; % Ambient temperature (Kelvin) for thermal noise model % Sensor parameters - P_TX = 10e-3; % Transmit power (Watts) - BW = 1e6; % Bandwidth (Hz) - f_c = 2e9; % Center frequency (Hz) + P_TX = NaN; % Transmit power (Watts) + BW = NaN; % Bandwidth (Hz) + f_c = NaN; % Center frequency (Hz) end methods (Access = public) - [obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); % TODO initialize sensor, define parameters + [obj] = initialize(obj, txPower, bandwidth, centerFreq); % TODO initialize sensor, define parameters [SINR] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); % 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 end diff --git a/test/test_rfSensor.m b/test/test_rfSensor.m index 61bcd79..c6495a1 100644 --- a/test/test_rfSensor.m +++ b/test/test_rfSensor.m @@ -8,18 +8,28 @@ classdef test_rfSensor < matlab.unittest.TestCase function tc = setup(tc) % Reinitialize sensor with random parameters tc.testClass = rfSensor; - % TODO - tc.testClass = tc.testClass.initialize(); end end methods (Test) - % Test methods + 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) + + tc.testClass = tc.testClass.initialize(P_TX, BW, f_c); - function test_SINR(tc) tc.testClass.plotParameters(); - % [SINR] = tc.testClass.sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); end - end + function plot_SINR(tc) + % Plot sensor performance with a single source of interference + P_TX = 1e-3; % Transmit power (Watts) + BW = 20e6; % Bandwidth (Hz) + f_c = 2e9; % Center frequency (Hz) + tc.testClass = tc.testClass.initialize(P_TX, BW, f_c); + + + end end \ No newline at end of file