[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: optimize code
From: |
c. |
Subject: |
Re: optimize code |
Date: |
Mon, 2 Dec 2013 14:15:41 +0100 |
On 2 Dec 2013, at 12:28, Jonas Åberg <address@hidden> wrote:
> It is a bit of a newbie problem this, but can this be vectorised?
> In principle I need to do
>
> for i=1:10
> vector(i)=rand
> endfor
>
> I would like to do it by using something that “looks” somewhat like this
> vector(1:10)=rand
> Where different random values are assigned to the different positions of the
> vector.
>
> Of course, the way I wrote it the same random value is assigned to all
> positions of vector, but I don’t want that…
>
> Is this possible?
>
vector = rand(10, 1);
this is explained in the the docs.
c,