Problem in Understanding Anonymous function

2 ビュー (過去 30 日間)
SRIHARSHA KORADA
SRIHARSHA KORADA 2016 年 2 月 27 日
回答済み: Star Strider 2016 年 2 月 28 日
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 件のコメント
dpb
dpb 2016 年 2 月 28 日
Fail to understand the request, sorry. What do you have from which to start and what is the desired result?

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2016 年 2 月 28 日
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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by