help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arguments out?


From: Thorsten Meyer
Subject: Re: Arguments out?
Date: Thu, 11 Dec 2003 18:10:14 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3.1) Gecko/20030425

Hi Vic,

try it like this:

function [a,b,c] = tete()
 if nargout == 0
   a = "zero";
 elseif nargout == 1
   a = "one";
 elseif nargout == 2
   a = "two";
   b = "one";
 elseif nargout == 3
   a = "three";
   b = "two";
   c = "one";
 end
endfunction

you'll get:
octave:9> tete
ans = null
octave:10> tete
ans = zero
octave:11> a=tete
a = one
octave:12> [a,b]=tete
a = two
b = one
octave:13> [d,e,f]=tete
d = three
e = two
f = one

Vic Norton wrote:

I'm afraid I don't understand how output arguments work in octave. I am writing a routine, simp, to solve the linear programming problem

   minimize
                 c * x
   subject to
               A * x = b
          prod( x(I) >= 0 ) == 1

The function should look like this

    [ x, pi, fail ] = simp( A, b, c, I )    #  pi * b == c * x

with nargout = 3. But, for nargout = 0, 1, 2, I would like it to return

    simp( A, b, c, I )                  #  nargout == 0, return ans = x
    x = simp( A, b, c, I )              #  nargout == 1
    [ x, fail ] = simp( A, b, c, I )    #  nargout == 2

Is this possible? Or do I have to use

    [ x, fail, pi ] = simp( A, b, c, I )

in order that the nargout = 0, 1, 2 returns be what I want?


Regards,

Vic




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]