From: Loren Shure on 18 Nov 2009 11:59 In article <hdv54a$pek$1(a)fred.mathworks.com>, cybeastfalzar99(a)yahoo.com says... > "Kenneth " <cybeastfalzar99(a)yahoo.com> wrote in message <hdv4h2$i63$1(a)fred.mathworks.com>... > > jrenfree <jrenfree(a)gmail.com> wrote in message <4a625840-b75a-4047-a4b1-464588be97b3(a)v15g2000prn.googlegroups.com>... > > > On Nov 17, 12:42?pm, "Kenneth " <cybeastfalza...(a)yahoo.com> wrote: > > > > i know how to replace the elements using m(x,y)=0 where m is the matrix, and x and y are the row and column position of the element. What I want to know is how to replace every other element in the matrix with zero. preferably using a for loop. > > > > > > Why would you prefer a for loop? You can specify index intervals > > > like: > > > > > > m(1:2:end, 1) = 0; > > > > > > That will make every other row of the 1st column equal to 0. > > > > I got it to work, but what i would like it to do now is alternate. so in the first row it will start at 1 and set every other one to zero, and in the second row it will start at 2 and set every other one. and so on, ect. also, it needs to work for any matrix(even 1000x1000) > what have you tried -- Loren http://blogs.mathworks.com/loren
First
|
Prev
|
Pages: 1 2 Prev: Cannot close matlabpool Next: Exponential Moving Average without For Loop |