Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Bug or Feature in find()?
Replies: 1   Last Post: Dec 9, 1996 12:28 AM

 Messages: [ Previous | Next ]
 James Michael Hammond Posts: 3 Registered: 12/7/04
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 row-or-column 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 |

Date Subject Author
12/7/96 James Michael Hammond
12/9/96 Dave Goodmanson