Main Content
spfun
Apply function to nonzero sparse matrix elements
Syntax
Description
applies the function F
= spfun(func
,S
)func
to the nonzero elements of a sparse matrix
S
. The input argument func
is a function handle to a
function that takes one input argument.
This operation preserves the sparsity of the original matrix S
unless
the function func
returns zero for some nonzero elements of
S
.
Examples
Input Arguments
Tips
If
func
returns zero for inputs that are zero, you can usefunc(S)
to return the same results as callingspfun
on a sparse matrixS
.
Extended Capabilities
Version History
Introduced before R2006a