Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Creating function from input argument

Subject: Creating function from input argument

From: Chris Burt

Date: 5 Aug, 2010 15:09:04

Message: 1 of 5

I'm creating a function that requires a mathematical function as an input argument(i.e. not a matlab function). I want to input f(x,y) and then the matlab function will calculate certain things relating to f(x,y). How can I make it so that f(x,y) is recognised as a function of x and y instead of a matrix?
Cheers.

Subject: Creating function from input argument

From: Sean

Date: 5 Aug, 2010 15:32:04

Message: 2 of 5

"Chris Burt" <chrisburt555@gmail.com> wrote in message <i3ek6g$40l$1@fred.mathworks.com>...
> I'm creating a function that requires a mathematical function as an input argument(i.e. not a matlab function). I want to input f(x,y) and then the matlab function will calculate certain things relating to f(x,y). How can I make it so that f(x,y) is recognised as a function of x and y instead of a matrix?
> Cheers

hint:
doc function_handle

Subject: Creating function from input argument

From: Andy

Date: 5 Aug, 2010 15:35:04

Message: 3 of 5

"Chris Burt" <chrisburt555@gmail.com> wrote in message <i3ek6g$40l$1@fred.mathworks.com>...
> I'm creating a function that requires a mathematical function as an input argument(i.e. not a matlab function). I want to input f(x,y) and then the matlab function will calculate certain things relating to f(x,y). How can I make it so that f(x,y) is recognised as a function of x and y instead of a matrix?
> Cheers.

It's unclear what you mean by "a mathematical function...not a matlab function". If you mean a custom made function, you should pass the function handle. If you mean a word which your function should recognize as the name of a mathematical function (which your function will then implement or process in some way), then you should probably pass the name of the function as a string.

Subject: Creating function from input argument

From: Walter Roberson

Date: 5 Aug, 2010 16:12:16

Message: 4 of 5

Chris Burt wrote:
> I'm creating a function that requires a mathematical function as an
> input argument(i.e. not a matlab function). I want to input f(x,y) and
> then the matlab function will calculate certain things relating to
> f(x,y). How can I make it so that f(x,y) is recognised as a function of
> x and y instead of a matrix?

If you need to do things like differentiate or calculate degrees, and
your function cannot be expressed as a ratio of multinomials with
integer or floating point coefficients, then you are probably need to
use a symbolic representation such as by using the symbolic toolbox.

Subject: Creating function from input argument

From: Chris Burt

Date: 5 Aug, 2010 16:40:08

Message: 5 of 5

"Chris Burt" <chrisburt555@gmail.com> wrote in message <i3ek6g$40l$1@fred.mathworks.com>...
> I'm creating a function that requires a mathematical function as an input argument(i.e. not a matlab function). I want to input f(x,y) and then the matlab function will calculate certain things relating to f(x,y). How can I make it so that f(x,y) is recognised as a function of x and y instead of a matrix?
> Cheers.
Thanks for the suggestions, I've sorted it using inline(f,x,y), turns out it wasn't a very complicated problem, I just didn't explain it very well!

Tags for this Thread

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.

Contact us