Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe15.iad.POSTED!7564ea0f!not-for-mail
From: "Nasser Abbasi" <nma@12000.org>
Newsgroups: comp.soft-sys.matlab
References: <h8adtb$r4u$1@fred.mathworks.com>
Subject: Re: [ab(1) ab(2) ... ab(N)] ~= [ab(1:N)] ???
Lines: 49
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3598
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
Message-ID: <IU3qm.419829$Ta5.328002@newsfe15.iad>
NNTP-Posting-Host: biclefbbodjieonkdgphainoamommick
X-Complaints-To: abuse@charter.net
X-Trace: ibafepnipngekpdoadefjppgkgeilljaaoipchbnblckniabbiclefbbodjieonkjkaeihcgcmpgdakkcekmjekhcoaghblcndpmaplcfceofgadopnghefflcicdbmdjdfippodjfioglha
NNTP-Posting-Date: Thu, 10 Sep 2009 09:45:12 UTC
Date: Thu, 10 Sep 2009 04:45:29 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:569478



"Andre Brito" <andre_brito23@hotmail.com> wrote in message 
news:h8adtb$r4u$1@fred.mathworks.com...

....

> 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];

Here you declare ab to be a vector of size 2

>>> ab = ind2sub([3 3],5)
>>> ab = 5

But here ind2sub overwrite your variable 'ab' which is a vector, with the 
outout of ind2sub. And since you prodvided one place for it to write its 
ouuput, it returned one of the output parameters and wrote that into 'ab', 
which is a scalar. You old vector 'ab' got expunged I am afraid.

If you wanted ind2sub to write into your vector 'ab', then do

EDU>> ab(1) = ind2sub([3 3],5)

ab =

     5     0

hth

--Nasser

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



> Cheers,
> Andre