Calculating log for each array element

Michael Goffioul michael.goffioul at gmail.com
Fri Jun 20 08:20:02 CDT 2008


On Fri, Jun 20, 2008 at 2:40 PM, DimitryASuplatov <genesup at gmail.com> wrote:
> Hello,
>
> I have array with some values initialized as
>
> a = load <filename>
>
> I want now to create another array b so as b[i] = log(a[i])
> I do this as follows
>
> for i = 1:length(a)
>        b(i) = log(a(i))
> endfor
>
> This works but it takes to long
>
> 1/ Is there any way to speed this up?

b = log(a);

> 2/ How to convert my array a to list?
> 3/ How to append to array?

vertical append: a = [a; rand(1,size(a,2))]
horizontal append: a = [a, rand(size(a,1),1)]

Michael.


More information about the Help-octave mailing list