[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help - two different syntaxes produce different results -typo in pre
From: |
Pantxo |
Subject: |
Re: help - two different syntaxes produce different results -typo in previous |
Date: |
Wed, 30 Oct 2019 08:43:00 -0500 (CDT) |
Carlo de Falco-2 wrote
> To get the same result in the two cases above you should modify the first
> one as follows:
>
>>> v = [68 73 77 85
> 95 85 104 99
> 68 181 162 92
> 98 130 123 93
> 94 87 87 88];
>>> [a, b]= find(v>100);
>>> ab = sub2ind (size (v), a, b);
>>> v(a,b)= 0;
As a side remark, you could also obtain the correct result with a third
indexing form, namely "logical indexing", which is often faster since it
avoids the "find" step:
v = [68 73 77 85
95 85 104 99
68 181 162 92
98 130 123 93
94 87 87 88];
v(v>100) = 0
Pantxo
--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html