how to take all non zero elements product of matrix

Answers (1)

KSSV
KSSV on 9 Nov 2016
Edited: KSSV on 9 Nov 2016
Let A me your matrix or array.
idx = A~=0;
iwant=prod(A(idx));
idx should be an array. If not change A matrix to column using
A=A(:);
And then use the above code.

Categories

Asked:

on 9 Nov 2016

Edited:

on 9 Nov 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!