How to modify a function handle?

조회 수: 8 (최근 30일)
Koki
Koki 2021년 5월 16일
답변: per isakson 2021년 5월 16일
Sorry I am not sure how to phrase the question but say I had a function handle say: myfun1 = @(y) y
Would I be able to modify that function and say something like myfun2 = @(y) myfun1*2
So when I write myfun2(5) it will return 10.
I essentially want to perform arithmetic on expressions representing functions of x to obtain other functions of x.

채택된 답변

per isakson
per isakson 2021년 5월 16일
That's simpler than you thought
%%
f1 = @(y) y;
f2 = @(y) f1(y)*2;
%%
f2(5)
ans = 10

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Handles에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by