Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Function output dimensions
Date: Wed, 9 Sep 2009 21:05:23 +0000 (UTC)
Organization: Universit&#228;t  Bremen
Lines: 19
Message-ID: <h895aj$85$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252530323 261 172.30.248.35 (9 Sep 2009 21:05:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 9 Sep 2009 21:05:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1426778
Xref: news.mathworks.com comp.soft-sys.matlab:569391


Basically, what I'm trying to do is to get the output of ind2sub (or of any function, for that matter) to output a vector and assign it to an existing vector. I know I could assign each element of the output to each element of the existing vector. The problem is when the dimensions of the output are not fixed.

(Maybe it has been answered before how it can be done, or that this is not the correct way to do it, or I'm missing something really obvious but I couldn't find a similar problem with the search terms I've used)

As an example, could someone just explain me what is the mechanism behind MATLAB that makes, for example, the function ind2sub output the following:

>> [a b] = ind2sub([3 3],5)
a = 2
b = 2

but if 
>> ab = [0 0];
>> ab = ind2sub([3 3],5)
ab = 5

Meaning that it does not detect that the output vector has dimensions different than 1x1.

Cheers,
Andr