|
From: <pl...@pi...> - 2014-11-04 11:42:08
|
On 11/04/14 05:14, sfeam wrote: > By the way, in the definition you show for function integ() > > integ(x)=(int_last==0)?(NaN,int_last=x):(int_last=int_last+x) > > the NaN has no effect whatsover because it is on the left > > side of a comma. That means the function reduces to > > integ(x) = (int_last = int_last+x) > > Ethan > Since this is a public archived list, I thought I ought to provide a more functionally correct version, just in case anyone uses it as an example. integ(x)=(!istarted)?(istarted=1,int_last=x):(int_last=int_last+x) plot istarted=0, datafile using 1:(integ($2-44)) with lines Now what I really need to do is skip the fn call if there is invalid data, so I try to trap the NaN in column 2: plot istarted=0, datafile using 1:(($2==NaN)?NaN:(integ($2-44))) with lines This produces the same unexpected results as before and the test is never true. Another consequence of NaNs not propagating. What is the correct way to trap this condition? (isNaN($2)) undefined function: isNaN ($2==NaN) never true ($2==0) not true for NaN in col 2 (exists($2) always true, even for NaN Is there currently a test condition that will trap NaN in the datafile ? Peter. |