refactoring for vectorization
This commit is contained in:
@@ -1,36 +1,26 @@
|
||||
function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensors, otherSensorsPos)
|
||||
function SINR = sensorPerformance(obj, d, t, d_other, t_other, otherSensors)
|
||||
arguments (Input)
|
||||
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||
agentPos (1, 3) double;
|
||||
targetPos (1, 3) double;
|
||||
otherSensors (:, 1) cell = {};
|
||||
otherSensorsPos (:, 3) double = NaN(0, 3);
|
||||
d (:, 1) double;
|
||||
t(:, 1) double;
|
||||
d_other (:, :) double = [];
|
||||
t_other (:, :) double = [];
|
||||
otherSensors (1, :) cell = {};
|
||||
end
|
||||
arguments (Output)
|
||||
SINR (:, 1) double;
|
||||
end
|
||||
assert(size(otherSensors, 1) == size(otherSensorsPos, 1), "Mismatch in length of other sensors (%d) and their positions (%d)", size(otherSensors, 1), size(otherSensorsPos, 1));
|
||||
|
||||
d = vecnorm(agentPos - targetPos, 2, 2); % distance from sensor to target
|
||||
d_other = NaN(size(otherSensors));
|
||||
|
||||
x = vecnorm(agentPos(1:2) - targetPos(1, 1:2), 2, 2); % distance from sensor nadir to target nadir (i.e. distance ignoring height difference)
|
||||
x_other = NaN(size(otherSensors));
|
||||
|
||||
t = (180 - atan2d(x, targetPos(1, 3) - agentPos(3))); % degrees
|
||||
t_other = NaN(size(otherSensors));
|
||||
assert(size(d, 1) == size(t, 1), "Mismatch in number of distance (%d) and angle (%d) pairs provided", size(d, 1), size(t, 1));
|
||||
assert(size(d_other, 1) == size(t_other, 1), "Mismatch in number of distances (%d) and tilts (%d) provided to other sensors", size(t, 1), size(t_other, 1));
|
||||
assert(size(d_other, 2) == size(t_other, 2), "Mismatch in number of other sensors given distances (%d) and tilts (%d)", size(d_other, 1), size(t_other, 1));
|
||||
assert(size(otherSensors, 2) == size(d_other, 2), "Mismatch in number of distances from other sensors (%d) and number of other sensors (%d) provided", size(d_other, 2), size(otherSensors, 2));
|
||||
|
||||
% Performance is measured as SINR for this sensor
|
||||
S = 10^(0.1 * obj.RSS(d, t)); % Signal
|
||||
N = obj.k_B * obj.T_0 * obj.BW; % Thermal noise
|
||||
I = 0; % Interference from other agents
|
||||
for ii = 1:size(otherSensors, 1)
|
||||
d_other(ii, 1) = vecnorm(otherSensorsPos(ii, 1:3) - targetPos, 2, 2);
|
||||
|
||||
x_other(ii, 1) = vecnorm(otherSensorsPos(ii, 3) - targetPos(1, 1:2), 2, 2);
|
||||
t_other(ii, 1) = (180 - atan2d(x_other(ii, 1), targetPos(1, 3) - otherSensorsPos(ii, 3)));
|
||||
|
||||
I = I + 10 ^ (0.1 * otherSensors.RSS(otherSensors{ii}, d_other(ii), t_other(ii)));
|
||||
S = 10 .^ (0.1 * obj.RSS(d, t)); % Signal
|
||||
I = zeros(size(d)); % Interference from other agents
|
||||
for ii = 1:size(otherSensors, 2)
|
||||
I = I + 10 .^ (0.1 * otherSensors{ii}.RSS(d_other(:, ii), t_other(:, ii)));
|
||||
end
|
||||
SINR = 10*log10(S/(I + N));
|
||||
|
||||
SINR = 10*log10(S ./ (I + obj.N));
|
||||
end
|
||||
Reference in New Issue
Block a user