Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: getting a list
Date: Mon, 1 Dec 2008 00:55:04 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 18
Message-ID: <ggvcl8$g43$1@fred.mathworks.com>
References: <ggupr9$280$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1228092904 16515 172.30.248.37 (1 Dec 2008 00:55:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 1 Dec 2008 00:55:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:503982


"Isabel" <isabels29@hotmail.com> wrote in message <ggupr9$280$1@fred.mathworks.com>...
> How can I get matlab to give me a list as the answer to a function? For example
> function [a,b]=add(T)
> a=2*T
> b=3*T
> everytime I do something like that, it only gives me back the first element. So in this case it would give me as an answer only 2*T.

I am going to guess you meant something different.  Do you mean, "How do I call a function so that it will return several variables?"  If so, say you have this function:

function [a,b]=add2(T) % Don't mask a built-in
a=2*T;
b=3*T;

Now at the command line call the function like this (for example):

>>[A,B]=add2(5)

You should have two new variables in your workspace.  The variable 'A' has a value of 10 and the variable 'B' has a value of 15.