Rank: 5094 based on 5 downloads (last 30 days) and 2 files submitted
photo

H. Brian Hui

E-mail

Personal Profile:

Biomedical Imaging Research Lab
Signal & Image Processing Institute
Department of Electrical Engineering
University of Southern California
http://neuroimage.usc.edu/hui/

Professional Interests:

 

Watch this Author's files

 

Files Posted by H. Brian View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui matrix 3 5
22 Jun 2007 Add folders to path excluding .svn Changes to genpath to exclude the .svn to the path Author: H. Brian Hui addpath, genpath, svn 2 0
Comments and Ratings by H. Brian
Updated File Comments Rating
19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui

Thanks Matt. Did not realize ind2sub can return n subscript arrays.

Comments and Ratings on H. Brian's Files View all
Updated File Comment by Comments Rating
08 Jul 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui Qureshi, Hafsa

I was trying something like x{1:length(L)}= ind2sub(L,IDX); but it gave error....thanks for posting the code. Still I wonder why my stat didn't work

19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui us

now, since others have backed-up my idea, you should soon come-up with an updated version...
us

19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui Hui, H. Brian

Thanks Matt. Did not realize ind2sub can return n subscript arrays.

19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui Fig, Matt

This seems a little faster for large number of dimensions:

IDX = find(A);
L = size(A);
[x{1:length(L)}] = ind2sub(L,IDX);
sub = [x{:}];
if nargout==2
v = A(IDX);
end

Something to consider.

19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui us

why not simply

% the data
a=zeros(2,3,4,5,6);
a(1,1,1,1,1)=1;
a(2,2,2,2,2)=2;
a(1,2,3,4,5)=3;
% the engine (in a function)
[ind{1:ndims(a)}]=ind2sub(size(a),find(a));
ind=cat(2,ind{:});
% the result
disp(ind)
%{
1 1 1 1 1
2 2 2 2 2
1 2 3 4 5
%}

just a thought...
us

Top Tags Applied by H. Brian
addpath, genpath, matrix, svn
Files Tagged by H. Brian View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui matrix 3 5
22 Jun 2007 Add folders to path excluding .svn Changes to genpath to exclude the .svn to the path Author: H. Brian Hui addpath, genpath, svn 2 0

Contact us