필터 지우기
필터 지우기

Problem in Understanding Anonymous function

조회 수: 1 (최근 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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by