From: Shiyuan Gu on
Hello,
I have a function, say f1(x,y,z); I want to create a function handle pointing to the function f2(x)=f1(x,yC,zC) where yC,zC are fixed and given at run-time.
I try fh=(a)f1(x,yC,zC) and it does not work.
How can I do that?
Thank you.
From: Steven Lord on

"Shiyuan Gu" <gshy2014(a)gmail.com> wrote in message
news:hhu79c$e43$1(a)fred.mathworks.com...
> Hello, I have a function, say f1(x,y,z); I want to create a function
> handle pointing to the function f2(x)=f1(x,yC,zC) where yC,zC are fixed
> and given at run-time. I try fh=(a)f1(x,yC,zC) and it does not work. How can
> I do that?

If you're using MATLAB 7.0 (R14) or later, use an anonymous function.

yC = 1;
zC = 2;
fh = @(x) f1(x, yC, zC)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ