help-octave
[Top][All Lists]
Advanced

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

Re: newbie question


From: Marco Atzeri
Subject: Re: newbie question
Date: Tue, 08 Nov 2011 23:05:32 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 11/8/2011 10:58 PM, TONY HOLDROYD wrote:
I have an array called X, say and I'd like to set the first column to
all zeros.
I can do it with a loop but would like to know how I can vectorise it
Thanks in advance
T.H.


help zeros

assuming you have a matrix like this

octave:5> a=rand(3,5)
a =

   0.47996   0.70635   0.21510   0.55275   0.54520
   0.35639   0.32545   0.25808   0.69724   0.14818
   0.91154   0.21920   0.52211   0.47036   0.75162

you can zeroed the first column in this way

octave:6> a(:,1)=zeros(size(a,1),1)
a =

   0.00000   0.70635   0.21510   0.55275   0.54520
   0.00000   0.32545   0.25808   0.69724   0.14818
   0.00000   0.21920   0.52211   0.47036   0.75162

Regards
Marco


reply via email to

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