Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: [ab(1) ab(2) ... ab(N)] ~= [ab(1:N)] ???
Date: Thu, 10 Sep 2009 10:29:05 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 17
Message-ID: <h8akdg$rqd$1@fred.mathworks.com>
References: <h8adtb$r4u$1@fred.mathworks.com> <IU3qm.419829$Ta5.328002@newsfe15.iad> <h8ai80$jp2$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252578545 28493 172.30.248.38 (10 Sep 2009 10:29:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 10 Sep 2009 10:29:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:569491


"Andre Brito" <andre_brito23@hotmail.com> wrote in message <h8ai80$jp2$1@fred.mathworks.com>...
> > You old vector 'ab' got expunged I am afraid.
> 
> Thanks, but do you have an idea how to do it without getting expunged?
> 

Try this:

abc = cell(size(ab));
[abc{:}] = ind2sub([3 3],2,2);
ab = [abc{:}]

Sorry but I don't have time right now to give a more proper explanation; but you should look at comma separated list, function calling, nargout.

You should also try to understand the way ind2sub contract the first input (size) with respect to the number of outputs.

Bruno