function ord=orderofmag(val) Returns the order of magnitude of the value of 'val' in multiples of 10 (e.g., 10^-1, 10^0, 10^1, 10^2, etc ...) used for computing erpimage trial axis tick labels as an alternative for plotting sorting variable
0001 function ord=orderofmag(val) 0002 %function ord=orderofmag(val) 0003 % 0004 % Returns the order of magnitude of the value of 'val' in multiples of 10 0005 % (e.g., 10^-1, 10^0, 10^1, 10^2, etc ...) 0006 % used for computing erpimage trial axis tick labels as an alternative for 0007 % plotting sorting variable 0008 0009 val=abs(val); 0010 if val>=1 0011 ord=1; 0012 val=floor(val/10); 0013 while val>=1, 0014 ord=ord*10; 0015 val=floor(val/10); 0016 end 0017 return; 0018 else 0019 ord=1/10; 0020 val=val*10; 0021 while val<1, 0022 ord=ord/10; 0023 val=val*10; 0024 end 0025 return; 0026 end