From: Tava Eurdanceza on 8 Apr 2010 21:52 Hi everyone. I have a problem. I want to make matrix 100 x 100 with elements 1 1 0 0 0 0 ... 0 0 0 0 1 1 0 0 ... 0 0 0 0 0 0 1 1 ... 0 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ... ⋮ ⋮ 0 0 0 0 0 0 ... 1 1 but it is not done by inserting elements one by one. how to create programs for the matrix? Thanks before
From: Matt Fig on 8 Apr 2010 22:00 See the help for the DIAG function.
From: Filip Leszko on 8 Apr 2010 23:53 how about: m=100; A = eye(m); A = A + [zeros(m,1) A(:,1:m-1)]
From: Roger Stafford on 9 Apr 2010 00:05 "Tava Eurdanceza" <tava_cute(a)yahoo.com> wrote in message <hpm187$b2n$1(a)fred.mathworks.com>... > Hi everyone. > I have a problem. I want to make matrix 100 x 100 with elements > 1 1 0 0 0 0 ... 0 0 > 0 0 1 1 0 0 ... 0 0 > 0 0 0 0 1 1 ... 0 0 > ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ... ⋮ ⋮ > 0 0 0 0 0 0 ... 1 1 > but it is not done by inserting elements one by one. > how to create programs for the matrix? > Thanks before As you have written it, that matrix cannot be a square 100 x 100. It would have to have twice as many columns as rows. What did you really intend? Roger Stafford
From: Roger Stafford on 9 Apr 2010 05:45
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hpm921$1rn$1(a)fred.mathworks.com>... > As you have written it, that matrix cannot be a square 100 x 100. It would have to have twice as many columns as rows. What did you really intend? > ........ -------------- In case you decide that a 100 x 200 size matrix is what you really want, you can do this: n = 100; A = zeros(n,2*n); A([1:2*n+1:n*(2*n-1),n+1:2*n+1:2*n^2]) = 1; Roger Stafford |