<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172</link>
    <title>MATLAB Central Newsreader - getting a list</title>
    <description>Feed for thread: getting a list</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 30 Nov 2008 19:34:02 -0500</pubDate>
      <title>getting a list</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172#614030</link>
      <author>Isabel </author>
      <description>How can I get matlab to give me a list as the answer to a function? For example&lt;br&gt;
function [a,b]=add(T)&lt;br&gt;
a=2*T&lt;br&gt;
b=3*T&lt;br&gt;
[2*T,3*T]&lt;br&gt;
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.&lt;br&gt;
What I've been doing is this:&lt;br&gt;
function z=add(T)&lt;br&gt;
z(1)=2*T&lt;br&gt;
z(2)=3*T&lt;br&gt;
end&lt;br&gt;
but I would like to know how to put a list as an output argument. Thanks!</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 19:52:36 -0500</pubDate>
      <title>Re: getting a list</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172#614032</link>
      <author>Walter Roberson</author>
      <description>Isabel wrote:&lt;br&gt;
&amp;gt; How can I get matlab to give me a list as the answer to a function? For example&lt;br&gt;
&amp;gt; function [a,b]=add(T)&lt;br&gt;
&amp;gt; a=2*T&lt;br&gt;
&amp;gt; b=3*T&lt;br&gt;
&amp;gt; [2*T,3*T]&lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; What I've been doing is this:&lt;br&gt;
&amp;gt; function z=add(T)&lt;br&gt;
&amp;gt; z(1)=2*T&lt;br&gt;
&amp;gt; z(2)=3*T&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; but I would like to know how to put a list as an output argument. Thanks!&lt;br&gt;
&lt;br&gt;
function z = add(T)&lt;br&gt;
z = [2*T, 3*T]&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
.signature note: I am now avoiding replying to unclear or ambiguous postings.&lt;br&gt;
Please review questions before posting them. Be specific. Use examples of what you mean,&lt;br&gt;
of what you don't mean. Specify boundary conditions, and data classes and value&lt;br&gt;
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 23:52:02 -0500</pubDate>
      <title>Re: getting a list</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172#614047</link>
      <author>Ryan Ollos</author>
      <description>&quot;Isabel&quot; &amp;lt;isabels29@hotmail.com&amp;gt; wrote in message &amp;lt;ggupr9$280$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; What I've been doing is this:&lt;br&gt;
&amp;gt; function z=add(T)&lt;br&gt;
&amp;gt; z(1)=2*T&lt;br&gt;
&amp;gt; z(2)=3*T&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; but I would like to know how to put a list as an output argument. Thanks!&lt;br&gt;
&lt;br&gt;
Your function seems to work fine for me.  I get z = [10 15] as the return argument.  Maybe you have a conflict with the built-in add function.  Run 'which add -all' and check if your function is being shadowed ... or just rename it.</description>
    </item>
    <item>
      <pubDate>Mon, 01 Dec 2008 00:55:04 -0500</pubDate>
      <title>Re: getting a list</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172#614052</link>
      <author>Matt Fig</author>
      <description>&quot;Isabel&quot; &amp;lt;isabels29@hotmail.com&amp;gt; wrote in message &amp;lt;ggupr9$280$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; How can I get matlab to give me a list as the answer to a function? For example&lt;br&gt;
&amp;gt; function [a,b]=add(T)&lt;br&gt;
&amp;gt; a=2*T&lt;br&gt;
&amp;gt; b=3*T&lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&lt;br&gt;
I am going to guess you meant something different.  Do you mean, &quot;How do I call a function so that it will return several variables?&quot;  If so, say you have this function:&lt;br&gt;
&lt;br&gt;
function [a,b]=add2(T) % Don't mask a built-in&lt;br&gt;
a=2*T;&lt;br&gt;
b=3*T;&lt;br&gt;
&lt;br&gt;
Now at the command line call the function like this (for example):&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;[A,B]=add2(5)&lt;br&gt;
&lt;br&gt;
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.</description>
    </item>
    <item>
      <pubDate>Mon, 01 Dec 2008 06:26:52 -0500</pubDate>
      <title>Re: getting a list</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240172#614089</link>
      <author>swgillan</author>
      <description>On Nov 30, 11:34=A0am, &quot;Isabel&quot; &amp;lt;isabel...@hotmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; How can I get matlab to give me a list as the answer to a function? For e=&lt;br&gt;
xample&lt;br&gt;
&amp;gt; function [a,b]=3Dadd(T)&lt;br&gt;
&amp;gt; a=3D2*T&lt;br&gt;
&amp;gt; b=3D3*T&lt;br&gt;
&amp;gt; [2*T,3*T]&lt;br&gt;
&amp;gt; everytime I do something like that, it only gives me back the first eleme=&lt;br&gt;
nt. So in this case it would give me as an answer only 2*T.&lt;br&gt;
&amp;gt; What I've been doing is this:&lt;br&gt;
&amp;gt; function z=3Dadd(T)&lt;br&gt;
&amp;gt; z(1)=3D2*T&lt;br&gt;
&amp;gt; z(2)=3D3*T&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; but I would like to know how to put a list as an output argument. Thanks!&lt;br&gt;
&lt;br&gt;
when you have a multi-variable output, you have to call it using an&lt;br&gt;
array of the output you want. Otherwise, if you just call with 1&lt;br&gt;
variable, you only get the first condition back:&lt;br&gt;
&lt;br&gt;
z =3D add(T) will only return the first output of your function&lt;br&gt;
[x y] =3D add(T) will return both properly.</description>
    </item>
  </channel>
</rss>

