Thread Subject: About Function Handle

Subject: About Function Handle

From: Shiyuan Gu

Date: 5 Jan, 2010 02:14:04

Message: 1 of 2

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=@f1(x,yC,zC) and it does not work.
How can I do that?
Thank you.

Subject: About Function Handle

From: Steven Lord

Date: 5 Jan, 2010 02:33:56

Message: 2 of 2


"Shiyuan Gu" <gshy2014@gmail.com> wrote in message
news:hhu79c$e43$1@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=@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@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
about function ... Shiyuan Gu 4 Jan, 2010 21:19:04
rssFeed for this Thread

Contact us at files@mathworks.com