[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: N_ELEMENTS and WHERE: Scalar or Array ?
>wh_one = where(x GT 1)
>x[wh_ine] = 0 ; NOTE the type
>Because of the typo, the second statement would have the mysterious
>side effect of having no effect at all! (including no error message) I
>would still love to have it, but newbies might go crazy.
For questions regarding subscript handling, it's always worth looking
at how MATLAB does things. They have a null array as a possible
variable, and seem to handle well what happens with this (logically
enough, when one indexes an array with a null array, the result is
null):
>> a = [1, 2]
a =
1 2
>> b = []
b =
[]
>> a(b)
ans =
[]
>>
>> whos
Name Size Bytes Class
a 1x2 16 double array
ans 0x0 0 double array
b 0x0 0 double array
Grand total is 2 elements using 16 bytes
David Ritscher
--
Cardiac Rhythm Management Laboratory
Department of Medicine
University of Alabama at Birmingham
B168 Volker Hall - 1670 University Boulevard
Birmingham AL 35294-0019
Tel: (205) 975-2122 Fax: (205) 975-4720
Email: david.ritscher@bigfoot.com