Path: news.mathworks.com!not-for-mail
From: "Gatis B" <s050995EXTRACHARACTERS@student.dtu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: 'switch' between function handles
Date: Thu, 8 May 2008 09:14:07 +0000 (UTC)
Organization: Tech.Univ. of Denmark
Lines: 28
Message-ID: <fvug8v$q0q$1@fred.mathworks.com>
Reply-To: "Gatis B" <s050995EXTRACHARACTERS@student.dtu.dk>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210238047 26650 172.30.248.37 (8 May 2008 09:14:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 May 2008 09:14:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1379868
Xref: news.mathworks.com comp.soft-sys.matlab:467337


 Hallo,
I have a function that has a parametrized function handle 
as one of its inputs. The function passed on to my 'main' 
function can be one option from a finite set, but each of 
these have different inputs from both inside my 'main' and 
from outside as parameters. So I would like to use 'switch' 
to evaluate which of my input functions I have, and act 
according to that..

The problem is that my input function is in the form:
@(x1,x2,x3)inpfcn(x1,x2,x3,par1,par2,par3)

Obviously I cannot switch between function handles, so I am 
using func2str, but with (par1,par2,par3) passed from 
outside the 'main' function, even that is not enough detect 
the right case. I would imagine this is a kind of a 
standard problem, but none of the options that 'doc 
function_handle' has leads to has provided any reasonable 
clue so far. I suppose one way would be to 'strfind' for 
what's between the first ')' and the second '(' in
@(x1,x2,x3)inpfcn(x1,x2,x3,par1,par2,par3)
to just get the sting with its name but that seems to 
awkward, taking into account that my 'main' is a state-
derivative function used for an ODE solver.

Thanks, I will be happy about any suggestions.
Regards,
/GB