help-octave
[Top][All Lists]
Advanced

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

Re: row vectors changed to column vectors?


From: Przemek Klosowski
Subject: Re: row vectors changed to column vectors?
Date: Tue, 10 Feb 2004 14:16:02 -0500 (EST)

   But what takes much more time is creating a N:N matrix out of these vectors.
   I have to "glue" the matrix using a() as a column, where for each column a()
   has to be "rotated" by one position. I tried first with two for loops. Now I

Would this be what you need:

 a=1:5 ; toeplitz(a,shift(fliplr(a),1)) 
  ans =

  1  5  4  3  2
  2  1  5  4  3
  3  2  1  5  4
  4  3  2  1  5
  5  4  3  2  1

or, Paul Kienzle's suggestion:

 fliplr(toeplitz(shift(a,1),fliplr(a)))
  ans =

  1  2  3  4  5
  2  3  4  5  1
  3  4  5  1  2
  4  5  1  2  3
  5  1  2  3  4



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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