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:
fast computing of differences between aij and aji

Subject: fast computing of differences between aij and aji

From: Paulo Guimaraes

Date: 16 Oct, 2012 14:47:09

Message: 1 of 3

Hi all,

I am working with a symmetric matrix A and I would like to compute the asymmetry

asymmetry = abs(a(i,j)- a(j,i)) for all i and all j.

Is there any way to compute this without two "fors"?

Thank you so much!

Subject: fast computing of differences between aij and aji

From: Ioanna

Date: 16 Oct, 2012 16:25:07

Message: 2 of 3

"Paulo Guimaraes" wrote in message <k5js1d$2ho$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I am working with a symmetric matrix A and I would like to compute the asymmetry
>
> asymmetry = abs(a(i,j)- a(j,i)) for all i and all j.
>
> Is there any way to compute this without two "fors"?
>
> Thank you so much!

If your matrix a is symmetric as you say, then asymmetry will be just a matrix of zeros...

Anyway, you can get the expression above without for loops:

asymmetry = abs(a-a')

Subject: fast computing of differences between aij and aji

From: Paulo Guimaraes

Date: 16 Oct, 2012 16:34:11

Message: 3 of 3

Thanks Ioanna!

I was inaccurate. The matrix is square and non-symmetrical.

Thank you

"Ioanna" wrote in message <k5k1p3$phb$1@newscl01ah.mathworks.com>...
> "Paulo Guimaraes" wrote in message <k5js1d$2ho$1@newscl01ah.mathworks.com>...
> > Hi all,
> >
> > I am working with a symmetric matrix A and I would like to compute the asymmetry
> >
> > asymmetry = abs(a(i,j)- a(j,i)) for all i and all j.
> >
> > Is there any way to compute this without two "fors"?
> >
> > Thank you so much!
>
> If your matrix a is symmetric as you say, then asymmetry will be just a matrix of zeros...
>
> Anyway, you can get the expression above without for loops:
>
> asymmetry = abs(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