It is an if condition on the single elements of a series
if (isnan(M[i]) = 1, i.e. the correspondent element of M is null) then
M[i] = 0 else
M[i] = M[i].
Bye
Giuseppe
On Wed, 2013-07-31 at 12:56 +0200, Artur T. wrote:
This is great! Actually, I was looking for something like this for a
while. Could anybody explain the single elements of this command,
please? It does not look very intuitive to me. Or is there reference in
the gretl guide on this?
M = isnan(M) ? 0 : M
Thank you.
Artur
Am 25.07.2013 11:28, schrieb Allin Cottrell:
> On Tue, 23 Jul 2013, Logan Kelly wrote:
>
>> I need to take the log difference of a matrix, i.e. log(M[2
>> rows(M):,]/M[1:rows(M)-1,]). Unfortunately, M has elements
>> equal to zero. I need to replace the nan's and inf's with
>> 0's. This almost works
>>
>> M = isnan(M) ? 0 : M
>>
>> but does not remove inf's. Any sugestions?
>
> Is this calculation actually legit? Assuming it is, then
>
> <hansl>
> matrix M = muniform(15,2)
> M[2,2] = 0
> M[3,2] = 0
> matrix ldM = log(M[2:rows(M),] - M[1:rows(M)-1,])
> ldM = isnan(0 * ldM) ? 0 : ldM
> print M ldM
> </hansl>
>
> This relies on the IEEE 754 rules: both 0*inf and 0*(-inf)
> return nan.
>
> Allin Cottrell
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users
>