help-octave
[Top][All Lists]
Advanced

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

Help needed on alternate row and column replacing matrix value


From: seltek
Subject: Help needed on alternate row and column replacing matrix value
Date: Mon, 15 Dec 2014 16:04:16 -0800 (PST)

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

For example:
>The first row, first column value of the initial matrix would replace the
first row,first column value of the new matrix 
>Then the first row, second column value of the initial matrix would replace
the first row, third column value of the new matrix

I tried making a do loop to do this but my loop would of course only work
for the first column and first row; I would like this to be done for every
odd row and column

Here is the loop I used:
N=3;
A=ones(N,N);
N_double=2*N;
C=zeros(N_double,N_double);
i=0;
do
i++;
j=(2*i)-1;
C(1,j)=A(i,1);
C(j,1)=A(1,i);
until(i==N);
C

I am quite new to using octave and any mathematical computing code so any
help would be appreciated and i hope i havnt made this sound too confusing
as i am struggling to explain this as it is 



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Help-needed-on-alternate-row-and-column-replacing-matrix-value-tp4667810.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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