```Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to enter conditional matrix
Date: Fri, 30 Mar 2012 09:19:09 -0400
Organization: MathWorks
Lines: 25
Message-ID: <jl4bsd\$7b3\$1@newscl01ah.mathworks.com>
References: <jl4amv\$2ng\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1333113549 7523 172.31.44.77 (30 Mar 2012 13:19:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 30 Mar 2012 13:19:09 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: news.mathworks.com comp.soft-sys.matlab:762676

"Kennedy Kwasi" <y2k394@gmail.com> wrote in message
news:jl4amv\$2ng\$1@newscl01ah.mathworks.com...
> How do i write a matlab script to generate an 80x80 matrix to satisfy the
> following conditions:
> for i=1:80; for j=1:80 , if j==i , a(i,j)=2*i
> else if j=i+2, for i=1:78 or j=i-2, for i=3:80, a(i,j)=0.5*i
> else if j=i+4, for i=1:76 or j=i-2, for i=5:80, a(i,j)=0.25*i
> else a(i,j)=0

No idea, because it looks like you're trying to nest a FOR loop over i
inside another FOR loop also over i.

If I had to guess I'd say the function you're looking for is DIAG, but if
you could show the group a small example (say 8-by-8) of the matrix you want
to result from running the code, the group may be able to offer more
specific help.

--
Steve Lord
slord@mathworks.com