FIND for n-D: Find indices and values of nonzero elements in n-D matrix
No License
Just like the FIND function in Matlab, FINDN is a simple function which will find the indices and values of nonzero elements in a n-D matrix
function [sub v] = findn(A)
% INPUT: A: n-D matrix
% OUTPUT: sub: the k x n index matrix (k is the number of the nonzeros)
v: a column or row vector v of the nonzero entries in A
USAGE:
[sub ] = findn(A)
TESTING CODE:
A = zeros(4,3,5,7);
A(4,2,1,4)=1;
A(2,3,4,6)=2;
A(1,2,3,4)=3;
findn(A)
AUTHOR:
Brian H. Hui (brianhui@alumni.usc.edu)
PhD candidate, Electrical Engineering, University of Southern California
Cite As
H. Brian Hui (2024). FIND for n-D: Find indices and values of nonzero elements in n-D matrix (https://www.mathworks.com/matlabcentral/fileexchange/23360-find-for-n-d-find-indices-and-values-of-nonzero-elements-in-n-d-matrix), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Linear Algebra >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |