On 11/12/19 8:45 AM, shivax via Help list for GNU Octave wrote:
> hi, look that:
> a=
> 1 0 0 8 7 0 0 2
> 0 0 0 0 0 0 0 0
> 2 0 0 6 0 0 1 0
>
> i want find vector with minimun non-zero
>
>
> and: 1 (minimun non-zero in rows n.1)
> 0 ( don't find minimum non-zero in rows n.2)
> 2 (minimun non-zero in rows n.3)
>
> it's possible to code it avoing loop?
>
Does this work for your problem?
a = [...
1 0 0 8 7 0 0 2; ...
0 0 0 0 0 0 0 0; ...
2 0 0 6 0 0 1 0];
a(a == 0) = inf;
b = min (a, [], 2);
b(isinf (b)) = 0
I think the answer for the third row should be "1", right?
HTH,
Kai