In octave, is there a build in function for replacing Inf/NaN to 0 in a vector
For example
a = log10([30 40 0 60]) => [1.4771 1.6021 -Inf 1.7782]
I can use finite or find function to find the index/position of the valid values
but I don’t know how to copy the values correctly without writing a function.
finite(a) => [1 1 0 1]
does the trick, this uses logical indexing
~is the NOT operator for boolean/logical values andisfinite(a)generates a logical vector, same size as a:As you can see, this is used for the logical indexing.