help-octave
[Top][All Lists]
Advanced

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

Re: Help needed on alternate row and column replacing matrix value


From: Andreas Weber
Subject: Re: Help needed on alternate row and column replacing matrix value
Date: Tue, 16 Dec 2014 12:51:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0

Am 16.12.2014 um 01:04 schrieb seltek:
> I wish to create a matrix that would use the values of initial matrix (for
> example a 3x3 ones matrix) to set the values in this new matrix (a 6x6
> matrix (or 2*Nx2*N))to be equal to the values of the initial matrix on every
> alternate column and row

This?

A = [4 2 7; 8 4 3; 7 9 2]

if (! issquare (A))
  error ("A has to be a suqare matrix")
endif

N = rows (A);
B = zeros (2 * N, 2 * N);
B(1:2:end, 1:2:end) = A

B =

   4   0   2   0   7   0
   0   0   0   0   0   0
   8   0   4   0   3   0
   0   0   0   0   0   0
   7   0   9   0   2   0
   0   0   0   0   0   0

-- Andy



reply via email to

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