help-octave
[Top][All Lists]
Advanced

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

How to allow for a parameter when callling another function


From: clustro
Subject: How to allow for a parameter when callling another function
Date: Tue, 3 May 2011 18:09:24 -0700 (PDT)

Hi there,

I am programming a function that minimizes another function. I call the
function like this:

Data = mcsa('ackley',x0)

where:

Data is the output (not important)
'ackley' is a function I wish to minimize (I have others; this is just an
example)
x0 is the initial-geuss vector.

Now, the ackley function, among others, can be altered by a parameter, n.
Currently, if I want to change n, I must manually go into ackley.m, change
it, and run the code again.

It would be more convenient if I could do it all in one shot. I tried
changing ackley to be y = ackley(x,n) (and commented out n in the rest of
the code), and ran the code like this:

Data = mcsa(@(x) ackley(x,n),x0)

But I get:

error: subscript indices must be either positive integers or logicals.

The error is on the first line where I use the "feval" function. Changing
@(x) ackley(x,n) to a string did not work either; Octave just didn't find
the file then.

Does anyone see a way to easily include for a parameter(S) in this
situation?

Thank you very much for your time,

-Brad Ridder

--
View this message in context: 
http://octave.1599824.n4.nabble.com/How-to-allow-for-a-parameter-when-callling-another-function-tp3494091p3494091.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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