[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: return values in functions
From: |
A S Hodel |
Subject: |
Re: return values in functions |
Date: |
Thu, 05 Apr 2001 22:10:13 -0500 |
Octave does not define functions in that way. You'll need to write an
mfile, e.g.:
g.m:
=====
function z = g(x,y)
z = exp(-0.52*x)*cos(8*3.14159*y);
endfunction
======
At the command line:
z = g(2,3)
alternatively:
x = 2 ; y = 3 ; eval("z = exp(-0.52*x)*cos(8*3.14159*y);");
----------
>From: Jonathan Drews <address@hidden>
>To: address@hidden
>Subject: return values in functions
>Date: Thu, Apr 5, 2001, 9:38 PM
>
>Hi:
>
> I am trying to assign the value of a function by using the following:
>
>octave:1> function z = g(x,y)
>> z = exp(-0.52*x)*cos(8*3.14159*y);
>> endfunction
>octave:2>
>octave:2> g(2,3)
>ans = 0.35345
>octave:3>
>octave:3> z
>error: `z' undefined near line 3 column 1
>error: evaluating expression near line 3, column 1
>octave:3>
>
>
> Is my install of Octave defective or am I doing this wrong. I am using
>version 2.0.16.
>--
> Cheers,
> Jonathan
>
>
>
>-------------------------------------------------------------
>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
>-------------------------------------------------------------
>
-------------------------------------------------------------
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
-------------------------------------------------------------