Commit 31fe591c authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

...

parent c1933f30
......@@ -240,7 +240,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
methods (Access = public)
function [z_idx, z_value] = findZeros(obj, optArg)
function [z_idx, z_grid, z_value] = findZeros(obj, optArg)
arguments
obj,
optArg.tol = 100*eps;
......@@ -259,6 +259,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
%ZeroX = @(x0,y0,x1,y1) x0 - (y0.*(x0 - x1))./(y0 - y1); % Interpolated x value for Zero-Crossing
z_idx{i} = unique( [zeros; upCrossing; downCrossing]);
z_grid{i} = obj(1).domain.grid(z_idx{i});
z_value{i} = data(z_idx{i});
end
end
......
......@@ -17,9 +17,10 @@ function testFindZeros(testCase)
x = quantity.Domain('x', linspace(0,1));
f = quantity.Discrete( sin( x.grid * 4 * pi ), 'domain', x);
[zIdx, zVal] = f.findZeros();
[zIdx, zGrid] = f.findZeros();
testCase.verifyEqual(zIdx{:}, [1 25, 50, 75, 100]');
testCase.verifyEqual(zGrid{:}, [0, 0.25, .5, .75, 1]', 'AbsTol', 0.01);
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment