Filter löschen
Filter löschen

Problem in Understanding Anonymous function

1 Ansicht (letzte 30 Tage)
SRIHARSHA KORADA
SRIHARSHA KORADA am 27 Feb. 2016
Beantwortet: Star Strider am 28 Feb. 2016
Hi, I am facing some problem to generate an array of anonymous functions. I need to generate like x+1,x+2..... up no x+n where x is a variable
@(i)(@(x)(i+x))
when i use the above one, I am getting arrays of x+i. Could someone help me?
  1 Kommentar
dpb
dpb am 28 Feb. 2016
Fail to understand the request, sorry. What do you have from which to start and what is the desired result?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 28 Feb. 2016
I would do this:
N = 5; % Define Constants
x = pi;
k = 1:N; % Define Vector
fcn = @(x,n) x + n; % Anonymous Function
Series = fcn(x,k)
Series =
4.1416 5.1416 6.1416 7.1416 8.1416

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by