Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fill a matrix
Date: Wed, 1 Aug 2007 07:47:56 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 18
Message-ID: <f8pdrc$nlr$1@canopus.cc.umanitoba.ca>
References: <f8pav4$pv1$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1185954476 24251 192.70.172.160 (1 Aug 2007 07:47:56 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Wed, 1 Aug 2007 07:47:56 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:422004


In article <f8pav4$pv1$1@fred.mathworks.com>,
Flavio Eripi <didad30@libero.it> wrote:
>Is there any command to put the values outside the diagonal of a matrix?
>For example if I want this matrix:
>a= [1,5,5,5;
>5,1,5,5;
>5,5,1,5;
>5,5,5,1];
>Thank you

V = 5;
a = magic(4);

cols = size(a,1);
a(~eye(cols)) = V;
-- 
  There are some ideas so wrong that only a very intelligent person
  could believe in them.                              -- George Orwell