help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculating log for each array element


From: LUK ShunTim
Subject: Re: Calculating log for each array element
Date: Fri, 20 Jun 2008 21:47:18 +0800
User-agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509)

DimitryASuplatov 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?

Most octave functions works on matrices.

octave:1> a=[1 2 3 4];
octave:2> log(a)
ans =

   0.00000   0.69315   1.09861   1.38629

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

Is this what you want?
octave:3> b=[a 10]
b =

    1    2    3    4   10

octave:4> c=[a b]
c =

    1    2    3    4    1    2    3    4   10


I really appreciate your help!
Thank you!

SDA

The octave manual is online at
http://www.gnu.org/software/octave/doc/interpreter/

Regards,
ST
--


reply via email to

[Prev in Thread] Current Thread [Next in Thread]