From: Shkelzen on
I have to generate in matlab a matrix with main diagonal zero, with row sum equal to 1 and to be symetrix. Please can anybody help me to give the .m file or to give some advices.
From: Matt on
"Shkelzen " <goxhjas(a)yahoo.com> wrote in message <hejfs5$r8k$1(a)fred.mathworks.com>...
> I have to generate in matlab a matrix with main diagonal zero, with row sum equal to 1 and to be symetrix. Please can anybody help me to give the .m file or to give some advices.

A=[0,1;1,0];
From: Jos (10584) on
"Shkelzen " <goxhjas(a)yahoo.com> wrote in message <hejfs5$r8k$1(a)fred.mathworks.com>...
> I have to generate in matlab a matrix with main diagonal zero, with row sum equal to 1 and to be symetrix. Please can anybody help me to give the .m file or to give some advices.

Here is some code for starters:

A = rand(4)
q1 = tril(true(4),-1)
q2 = triu(true(4),1)
A(q1) = A(q2) % symmetry
A(eye(4)==1) = 0 % set diagonal to zero

help rand
help diag
help eye
help tril
help triu

hth
Jos
From: Shkelzen on
I gonna try
Thank you!

"Jos (10584) " <#10584(a)fileexchange.com> wrote in message <hejiar$3q9$1(a)fred.mathworks.com>...
> "Shkelzen " <goxhjas(a)yahoo.com> wrote in message <hejfs5$r8k$1(a)fred.mathworks.com>...
> > I have to generate in matlab a matrix with main diagonal zero, with row sum equal to 1 and to be symetrix. Please can anybody help me to give the .m file or to give some advices.
>
> Here is some code for starters:
>
> A = rand(4)
> q1 = tril(true(4),-1)
> q2 = triu(true(4),1)
> A(q1) = A(q2) % symmetry
> A(eye(4)==1) = 0 % set diagonal to zero
>
> help rand
> help diag
> help eye
> help tril
> help triu
>
> hth
> Jos
From: Shkelzen on
I try the way u tll me, the matrix is OK exept the fact that dont have rows sum equale to 1. Please can u help me make this matrix or is inposible to do a matrix like this.

Thx again !!


"Shkelzen " <goxhjas(a)yahoo.com> wrote in message <helsem$d7p$1(a)fred.mathworks.com>...
> I gonna try
> Thank you!
>
> "Jos (10584) " <#10584(a)fileexchange.com> wrote in message <hejiar$3q9$1(a)fred.mathworks.com>...
> > "Shkelzen " <goxhjas(a)yahoo.com> wrote in message <hejfs5$r8k$1(a)fred.mathworks.com>...
> > > I have to generate in matlab a matrix with main diagonal zero, with row sum equal to 1 and to be symetrix. Please can anybody help me to give the .m file or to give some advices.
> >
> > Here is some code for starters:
> >
> > A = rand(4)
> > q1 = tril(true(4),-1)
> > q2 = triu(true(4),1)
> > A(q1) = A(q2) % symmetry
> > A(eye(4)==1) = 0 % set diagonal to zero
> >
> > help rand
> > help diag
> > help eye
> > help tril
> > help triu
> >
> > hth
> > Jos