help-octave
[Top][All Lists]

## Re: function definition

 From: Søren Hauberg Subject: Re: function definition Date: Tue, 12 Apr 2005 20:02:11 +0200 User-agent: Mozilla Thunderbird 1.0.2 (X11/20050404)

```Hi
If I understand your problem correctly you can do something like this:

function [ ret ] = some_name (a, b, x)
ret = a(x) + b(x);
endfunction

And then call this function with arguments like this:

some_name( @sin, @cos, 3)

which will give you the value of sin(3) + cos(3)

hope that helps,
Søren

```
```
Hello,

I've got a problem, which, I'm sure will have a trivial solution:

I need to define a function as a linear combination of other functions, like

f(x)=a(x)+b(x)

How can I do it in Octave?

```
Thanks a lot,
```Hana.

-------------------------------------------------

-------------------------------------------------------------
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
-------------------------------------------------------------

```