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:
anonymous function output choice

Subject: anonymous function output choice

From: Floris Zoutman

Date: 19 Nov, 2010 14:37:03

Message: 1 of 2

I have a function with vector input and output basically y=fun(x). I would like to make an (anonymous) function which produces scalar output y(i) as a function of scalar input x(i) for given values of x(j) where j is not i. If x0 is the initial value of x I can write a function:
fun2=@(x)fun([x0(1:i-1);x;x0(i+1:end]);
In fun2 vector y is a function of x(i). However, I do not see how to make the function only give y(i) as an output. Can somebody help me? Many thanks in advance.
best,
Floris

Subject: anonymous function output choice

From: Mike Karr

Date: 24 Nov, 2010 13:12:47

Message: 2 of 2

Floris Zoutman wrote:
> I have a function with vector input and output basically y=fun(x). I
> would like to make an (anonymous) function which produces scalar output
> y(i) as a function of scalar input x(i) for given values of x(j) where j
> is not i. If x0 is the initial value of x I can write a function:
> fun2=@(x)fun([x0(1:i-1);x;x0(i+1:end]);
> In fun2 vector y is a function of x(i). However, I do not see how to
> make the function only give y(i) as an output. Can somebody help me?
> Many thanks in advance.
> best,
> Floris


 >> f = @() deal(0,1); [a,b] = f()
a =
      0
b =
      1

hth,
mike

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