Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Subscript indices
Date: Fri, 20 Feb 2009 12:09:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 26
Message-ID: <gnm6gu$9ka$1@fred.mathworks.com>
References: <gne9b2$46o$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235131742 9866 172.30.248.37 (20 Feb 2009 12:09:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 20 Feb 2009 12:09:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:519660


"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gne9b2$46o$1@fred.mathworks.com>...
> Hi,
> I have the following loop:
> 
> for x=[0.001:0.001:0.1]
> result(x)=y;
> end
> 
> The problem is that I get the following error message: "Subscript indices must either be real positive integers or logicals". So is there a way I can make it without that error?
> 
> Thanks a lot.

Actually you could do this:

x=[0.001:0.001:0.1];
result=containers.Map(inf,inf); % create with dummy
for x=[0.001:0.001:0.1]
    y=rand();
    result(x)=y;
end
remove(result,Inf); % remove the dummy

x=0.002
result(x) % beware of floating-point limited precision...

% Bruno