From: amit sharma on
dear sir

I have a matrix of real number, how to make it's diagonal element zero


From: dpb on
amit sharma wrote:
> I have a matrix of real number, how to make it's diagonal element zero

one of an almost limitless number of ways...

x(eye(size(x))>0)=0;

--

From: Wayne King on
amit sharma <sharma.a28(a)gmail.com> wrote in message <6a6ded57-f244-460b-95db-7867c46419db(a)n20g2000prh.googlegroups.com>...
> dear sir
>
> I have a matrix of real number, how to make it's diagonal element zero
>

Hi,
One of many ways:

V = randn(3,2);
A = abs(eye(3,2)-ones(3,2));
B = V.*A;

If the matrices are square, you can simplify a bit:

V = randn(3);
A = abs(eye(3)-ones(3));
B = V.*A;

Hope that helps,
Wayne
From: amit sharma on
On Jun 5, 8:54 pm, dpb <n...(a)non.net> wrote:
> amit sharma wrote:
> > I have a matrix of real number, how to make it's diagonal element zero
>
> one of an almost limitless number of ways...
>
> x(eye(size(x))>0)=0;
>
> --

thanks