changeset 1068:a9c30f62cb2e octave-forge

cleaned up code; double division changed to mul and single div; check of DIM argument cleaner
author schloegl
date Thu, 09 Oct 2003 09:00:50 +0000
parents 76e1a6f67810
children 44eeb81593b2
files extra/NaN/zscore.m
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/extra/NaN/zscore.m	Thu Oct 09 08:27:03 2003 +0000
+++ b/extra/NaN/zscore.m	Thu Oct 09 09:00:50 2003 +0000
@@ -19,7 +19,7 @@
 % see also: SUMSKIPNAN, MEAN, STD, DETREND
 %
 % REFERENCE(S):
-% http://mathworld.wolfram.com/z-Score.html
+% [1] http://mathworld.wolfram.com/z-Score.html
 
 %    This program is free software; you can redistribute it and/or modify
 %    it under the terms of the GNU General Public License as published by
@@ -41,15 +41,16 @@
 %	$Id$
 
 
-if nargin==1,
-        DIM=min(find(size(i)>1));
-        if isempty(DIM), DIM=1; end;
+if any(size(i)==0); return; end;
+
+if nargin < 2,
+	[S,N,SSQ] = sumskipnan(i);		% sum
+else
+	[S,N,SSQ] = sumskipnan(i,DIM);		% sum
 end;
 
-if any(size(i)==0); return; end;
-
-[S,N,SSQ] = sumskipnan(i,DIM);		% sum
 M = S./N;
 i = i - repmat(M,size(i)./size(S));		% remove mean
-i = i./repmat(sqrt((SSQ-real(S).*real(M)-imag(S).*imag(M))./max(N-1,0)),size(i)./size(S));	 % normalize by STD
+i = i.*repmat(sqrt((SSQ-real(S).*real(M)-imag(S).*imag(M)).\max(N-1,0)),size(i)./size(S));	 % normalize by STD
 
+