Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!a29g2000pra.googlegroups.com!not-for-mail
From: swgillan <swgillan@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: getting a list
Date: Sun, 30 Nov 2008 22:26:52 -0800 (PST)
Organization: http://groups.google.com
Lines: 22
Message-ID: <f14cb2fd-ae4b-432c-8141-9c4f8fc7c958@a29g2000pra.googlegroups.com>
References: <ggupr9$280$1@fred.mathworks.com>
NNTP-Posting-Host: 24.108.200.44
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1228112813 5074 127.0.0.1 (1 Dec 2008 06:26:53 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 1 Dec 2008 06:26:53 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a29g2000pra.googlegroups.com; posting-host=24.108.200.44; 
	posting-account=oG0_2QoAAADs2vBCPqAYFyNKpnhzubZa
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4) 
	Gecko/2008102920 Firefox/3.0.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:504019


On Nov 30, 11:34=A0am, "Isabel" <isabel...@hotmail.com> wrote:
> How can I get matlab to give me a list as the answer to a function? For e=
xample
> function [a,b]=3Dadd(T)
> a=3D2*T
> b=3D3*T
> [2*T,3*T]
> everytime I do something like that, it only gives me back the first eleme=
nt. So in this case it would give me as an answer only 2*T.
> What I've been doing is this:
> function z=3Dadd(T)
> z(1)=3D2*T
> z(2)=3D3*T
> end
> but I would like to know how to put a list as an output argument. Thanks!

when you have a multi-variable output, you have to call it using an
array of the output you want. Otherwise, if you just call with 1
variable, you only get the first condition back:

z =3D add(T) will only return the first output of your function
[x y] =3D add(T) will return both properly.