```Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: matrix indexing
Date: Mon, 27 Feb 2012 09:23:49 -0500
Organization: MathWorks
Lines: 38
Message-ID: <jig3ll\$k7d\$1@newscl01ah.mathworks.com>
References: <jif55e\$jfa\$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 1330352629 20717 172.31.44.77 (27 Feb 2012 14:23:49 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 27 Feb 2012 14:23:49 +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:759159

"merew " <merew95@yahoo.com> wrote in message
news:jif55e\$jfa\$1@newscl01ah.mathworks.com...
> I want to fill a square matrix using nested for loops. I have the
> following nested loop that computes the values to be filled in the matrix:
>
> D=zeros((L+1)^2,(L+1)^2);
> for l=0:L
> for m=-l:l
>     value=x;
>     D(?)=x;
> end
> end
>
> If L=2, the dimension of D is 3x3 and the nested for loops produce 9
> values to be filled in the matrix D.
>

Please do NOT both email me and post to the newsgroup; posting to the group
is sufficient.

I recommend you review the section of the documentation that discusses
indexing:

http://www.mathworks.com/help/techdoc/math/f1-85462.html

Only you know how exactly you want to fill in D, so only you will be able to
generate the necessary indices unless you show _the group_ what exactly
you're trying to do.

--
Steve Lord
slord@mathworks.com