Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Bug or Feature in find()?
Posted:
Dec 7, 1996 11:40 AM


I'm using MATLAB 4.2c dated Dec 31 1994 on a SunOS 4.x machine.
If I use find with zero (or one) output parameter(s) on a full vector, the answer will be in the same roworcolumn orientation as the input:
>> a = rand(4); >> find(a(1,:))
ans =
1 2 3 4
>> find(a(:,1))
ans =
1 2 3 4
but if I use it on a sparse row or column vector, the answer will always be a column vector:
>> a = sparse(a); >> find(a(1,:))
ans =
1 2 3 4
>> find(a(:,1))
ans =
1 2 3 4
This not only cost me a small but annoying amount of time trying to figure out why my nifty slick "pull out the innermost loop with vectorization" trick was failing, but also cost the MathWorks a little bit of free advertising, as the professor who was watching me try to prove how much easier it is to code numerical stuff in MATLAB than in C remained unimpressed.
JMike  J Michael Hammond <hammond@cs.utk.edu>  Univ of Tenn Dept of Comp Sci  http://www.cs.utk.edu/~hammond/jmike.html 



