Prev: How to align two time series fast?
Next: using fuzzy toolbox inside stateflow simulink function
From: Matt J on 21 Jul 2010 15:56 Here's a bit more embellished version of my last example that uses the oneWithTol() function down at the bottom of the post to create the object in a single line. The object returned by oneWithTol allows you to do a series of tolerance-qualified comparisons with arbitrary numbers, all without function call syntax. l=oneWithTol(.01); %Represents the number 1 with a tolerance of .01 %%Comparison operations >> sum([.4 .3 .2 .1001])==l %Equal to one within tolerance of .01 ans = 1 >> sum([.4 .3 .2 .1001 9])==l %Not equal to one within tolerance of .01 ans = 0 >> sum([.4 .3 .2 .1001 9])==10*l %But it is equal to 10 within the tolerance ans = 1 >> sum([.4 .3 .2 .15 9])==10*l %Not equal to 10 within the tolerance ans = 0 function FuzzyOne=oneWithTol(tol,val) %FuzzyOne=oneWithTol(tol) - Returns an object FuzzyOne representing the %scalar 1, but with the property that operations expression==FuzzyOne will %be evaluated with the input tolerance, tol % %Also, FuzzyOne can be scaled arbitrarily c*FuzzyOne to permit comparisons %with numbers other than one. if nargin<2, val=1; end %for now extra argout only used internally FuzzyOne=MatrixObj; FuzzyOne.Params.tol=tol; FuzzyOne.Params.val=val; FuzzyOne.Ops.eq=@(x,A) abs(A.Params.val-x)<=A.Params.tol; FuzzyOne.Ops.mtimes=@(c,A) oneWithTol(A.Params.tol,c*A.Params.val);
From: Brandon Moore on 21 Jul 2010 16:30 Walter Roberson <roberson(a)hushmail.com> wrote in message > histc() reserves the final output bin to count values that are exact equal to > the last provided edge. If comparisons suddenly became slightly fuzzy in the > manner described ("erring on the side of logical true"), then > > x < x > > and > > x == x > > would both be true and it would then be ambiguous as to whether the values > exactly matching the last edge should be counted towards the second-last bin > or toward the final bin or both. Good point. Probably better to leave this alone and deal with approximation problems explicitly. At least until someone invents a computer that works with real numbers.
|
Pages: 1 Prev: How to align two time series fast? Next: using fuzzy toolbox inside stateflow simulink function |