Got Questions? Get Answers.
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:
to make adjacent matrix

Subject: to make adjacent matrix

From: amit sharma

Date: 12 May, 2010 04:32:58

Message: 1 of 6

dear sir


I want to make 10X10 adjacent matrix in which every row and colom have
5 one's .
Matrix should be symmetric.


waiting for ur response

Subject: to make adjacent matrix

From: Roger Stafford

Date: 12 May, 2010 06:11:04

Message: 2 of 6

amit sharma <sharma.a28@gmail.com> wrote in message <7e14b2c2-8016-4254-9a69-aec4777e8b5d@r21g2000prr.googlegroups.com>...
> dear sir
> I want to make 10X10 adjacent matrix in which every row and colom have
> 5 one's .
> Matrix should be symmetric.
> waiting for ur response

  How about a chess board arrangement except that it is 10 x 10? The black squares are the 1's and the white squares are the 0's.

 M = [1 0 1 0 1 0 1 0 1 0;
      0 1 0 1 0 1 0 1 0 1;
      1 0 1 0 1 0 1 0 1 0;
      0 1 0 1 0 1 0 1 0 1;
      1 0 1 0 1 0 1 0 1 0;
      0 1 0 1 0 1 0 1 0 1;
      1 0 1 0 1 0 1 0 1 0;
      0 1 0 1 0 1 0 1 0 1;
      1 0 1 0 1 0 1 0 1 0;
      0 1 0 1 0 1 0 1 0 1];

You can generate this with a toeplitz function.
 
Roger Stafford

Subject: to make adjacent matrix

From: Roger Stafford

Date: 12 May, 2010 06:33:04

Message: 3 of 6

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hsdgpo$8aq$1@fred.mathworks.com>...
> amit sharma <sharma.a28@gmail.com> wrote in message <7e14b2c2-8016-4254-9a69-aec4777e8b5d@r21g2000prr.googlegroups.com>...
> > dear sir
> > I want to make 10X10 adjacent matrix in which every row and colom have
> > 5 one's .
> > Matrix should be symmetric.
> > waiting for ur response
>
> How about a chess board arrangement except that it is 10 x 10? The black squares are the 1's and the white squares are the 0's.
>
> M = [1 0 1 0 1 0 1 0 1 0;
> 0 1 0 1 0 1 0 1 0 1;
> 1 0 1 0 1 0 1 0 1 0;
> 0 1 0 1 0 1 0 1 0 1;
> 1 0 1 0 1 0 1 0 1 0;
> 0 1 0 1 0 1 0 1 0 1;
> 1 0 1 0 1 0 1 0 1 0;
> 0 1 0 1 0 1 0 1 0 1;
> 1 0 1 0 1 0 1 0 1 0;
> 0 1 0 1 0 1 0 1 0 1];
>
> You can generate this with a toeplitz function.
>
> Roger Stafford

  Or how about any permutation made on both the columns and rows of M:

 p = randperm(10);
 M2 = M(p,p);

That would give you a large variety to choose from.

Roger Stafford

Subject: to make adjacent matrix

From: amit sharma

Date: 12 May, 2010 08:13:13

Message: 4 of 6

On May 12, 11:11 am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> amit sharma <sharma....@gmail.com> wrote in message <7e14b2c2-8016-4254-9a69-aec4777e8...@r21g2000prr.googlegroups.com>...
> > dear sir
> > I want to make 10X10 adjacent matrix in which every row and colom have
> > 5  one's .
> > Matrix should be symmetric.
> > waiting for ur response
>
>   How about a chess board arrangement except that it is 10 x 10?  The black squares are the 1's and the white squares are the 0's.
>
>  M = [1 0 1 0 1 0 1 0 1 0;
>       0 1 0 1 0 1 0 1 0 1;
>       1 0 1 0 1 0 1 0 1 0;
>       0 1 0 1 0 1 0 1 0 1;
>       1 0 1 0 1 0 1 0 1 0;
>       0 1 0 1 0 1 0 1 0 1;
>       1 0 1 0 1 0 1 0 1 0;
>       0 1 0 1 0 1 0 1 0 1;
>       1 0 1 0 1 0 1 0 1 0;
>       0 1 0 1 0 1 0 1 0 1];
>
> You can generate this with a toeplitz function.
>
> Roger Stafford

selection of the number is random, then how to do it?

Subject: to make adjacent matrix

From: Bruno Luong

Date: 12 May, 2010 08:18:04

Message: 5 of 6

amit sharma <sharma.a28@gmail.com> wrote in message <aa3603ac-59b4-407e-b95a-1b20b2bba631@s13g2000prc.googlegroups.com>...

>
> selection of the number is random, then how to do it?

Please see Roger's second post.

Bruno

Subject: to make adjacent matrix

From: Andrew Krieger

Date: 19 Nov, 2012 03:51:10

Message: 6 of 6

amit sharma <sharma.a28@gmail.com> wrote in message <7e14b2c2-8016-4254-9a69-aec4777e8b5d@r21g2000prr.googlegroups.com>...
> dear sir
>
>
> I want to make 10X10 adjacent matrix in which every row and colom have
> 5 one's .
> Matrix should be symmetric.
>
>
> waiting for ur response

This is more general: Generate a random adjacency matrix with weighting.

% function [A]=adjmatrix(n);
% This code generates a random adjacency matrix of programmable size n
% Generates the upper triangulat portion of the matrix by cycling through
% every upper triangular element and assign 1 or 0 with 50/50 probability
% then add the transpose to itself to get the lower triangular portion to
% match, row to column, the upper trangular portion-- this makes it adj...
% add weight w, w=.5 results in all zeros, w>>1 leads to mostly 1's
% w=1 leads to a 50/50 chance of a connection at each node
function [A]=adjmatrix(n,w);
A=zeros(n,n);
k=1;
for j=1:n-1 % Go through each row
    for k=j+1:n % Go through each column of the row chosen above
    A(j,k)=round(rand*w);
    if A(j,k)>1
       A(j,k)=1;
    end
    end
end
   % Now formulate the lower triangular portion to make it an adjacency
   % matrix
A=A+A';

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