On Thu, 27 Sep 2018, Sven Schreiber wrote:
On Wed, 26 Sep 2018, Sven Schreiber wrote:
>>
>>> OK, sorry for the delay. I'm attaching an attempt
Minor correction: The included helper function matof (as in: matrix variant
of atof) had a little redundancy, because atof itself already handles empty
strings. Here's the update:
<hansl>
function matrix matof(strings in, int skip[0::0])
# Returns column vector with the numerical values in the string array.
# 'skip' refers to how many leading array elements should be discarded.
N = nelem(in)
matrix m = ones(N - skip,1) * $huge # initialize to nonsense
loop i = 1+skip .. N --quiet
m[i - skip] = atof(in[i])
endloop
return m
end function
</hansl>
I was wondering, yesterday, when looking at your code: why initialise m to
$huge? wouldn't
matrix m = mshape(NA, N - skip, 1)
do?
And another thing: it may make sense to expand atof() so as to return
automatically a column vector if the argument is a string array. Or am I
missing something?
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------