Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix 100 x 100

Subject: matrix 100 x 100

From: Tava Eurdanceza

Date: 9 Apr, 2010 01:52:07

Message: 1 of 8

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

Subject: matrix 100 x 100

From: Matt Fig

Date: 9 Apr, 2010 02:00:23

Message: 2 of 8

See the help for the DIAG function.

Subject: matrix 100 x 100

From: Filip Leszko

Date: 9 Apr, 2010 03:53:05

Message: 3 of 8

how about:
m=100;
A = eye(m);
A = A + [zeros(m,1) A(:,1:m-1)]

Subject: matrix 100 x 100

From: Roger Stafford

Date: 9 Apr, 2010 04:05:21

Message: 4 of 8

"Tava Eurdanceza" <tava_cute@yahoo.com> wrote in message <hpm187$b2n$1@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

Subject: matrix 100 x 100

From: Roger Stafford

Date: 9 Apr, 2010 09:45:24

Message: 5 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hpm921$1rn$1@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

Subject: matrix 100 x 100

From: Bruno Luong

Date: 9 Apr, 2010 10:11:05

Message: 6 of 8

kron(eye(100),[1 1]) % 100 x 200, see Roger's remark

% Or sparse

kron(speye(100),[1 1])

% Bruno

Subject: matrix 100 x 100

From: Tava Eurdanceza

Date: 10 Apr, 2010 00:43:04

Message: 7 of 8

Thanks a lot guys

Subject: matrix 100 x 100

From: TessaLe

Date: 26 Feb, 2011 06:12:52

Message: 8 of 8

freelance writer

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us