Skip to content

Commit 6745670

Browse files
HanSur94claude
andcommitted
fix(FastSense): use Value field for scalar resolved thresholds
ResolvedThresholds with empty X/Y arrays are scalar thresholds stored in the Value field. The previous fix tried th.Y(1) which crashes on empty arrays. Now correctly uses th.Value for scalar thresholds and falls back to th.Y(1) only if Value is empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7cafa20 commit 6745670

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

libs/FastSense/FastSense.m

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -575,22 +575,21 @@ function addSensor(obj, sensor, varargin)
575575
thLabel = sprintf('Threshold %d', i);
576576
end
577577
[thColor, thStyle] = obj.resolveThresholdStyle(th.Color, th.LineStyle);
578-
if numel(th.X) <= 1
579-
% Single-point or scalar — use scalar form
580-
thVal = th.Y(1);
581-
obj.addThreshold(thVal, ...
582-
'Direction', th.Direction, ...
583-
'ShowViolations', true, ...
584-
'Label', thLabel, ...
585-
'Color', thColor, ...
586-
'LineStyle', thStyle);
578+
nvArgs = {'Direction', th.Direction, ...
579+
'ShowViolations', true, ...
580+
'Label', thLabel, ...
581+
'Color', thColor, ...
582+
'LineStyle', thStyle};
583+
if ~isempty(th.X) && numel(th.X) > 1
584+
% Time-varying threshold
585+
obj.addThreshold(th.X, th.Y, nvArgs{:});
587586
else
588-
obj.addThreshold(th.X, th.Y, ...
589-
'Direction', th.Direction, ...
590-
'ShowViolations', true, ...
591-
'Label', thLabel, ...
592-
'Color', thColor, ...
593-
'LineStyle', thStyle);
587+
% Scalar threshold — use Value field
588+
thVal = th.Value;
589+
if isempty(thVal) && ~isempty(th.Y)
590+
thVal = th.Y(1);
591+
end
592+
obj.addThreshold(thVal, nvArgs{:});
594593
end
595594
end
596595
end

0 commit comments

Comments
 (0)