kr.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html
function handle(ํจ์ ํธ๋ค): ํจ์๋ฅผ ๊ฐ์ ์ ์ผ๋ก ํธ์ถํ๋ค.
์ฉ๋:
- ํจ์๋ฅผ ๋ค๋ฅธ ํจ์์ ์ ๋ฌํ ๋ ์ฌ์ฉํ ์ ์์.
- ํจ์๋ฅผ ์ ์ํ์ง ์๊ณ ๋ฐ๋ก ์ฌ์ฉํ ์ ์์.
- Python์ Labmda ์๊ณผ ๋์ผํ๋ค.
๊ณจ๋ฑ ์ด @ ๊ธฐํธ๋ฅผ ์ด์ฉํ๋ค.
f = @myfunction
Example)
function y = computeSquare(x)
y = x.^2;
end
f = @computeSquare;
y = f(4)
> y = 16
์ต๋ช ํจ์
ํจ์ ํ์ผ์ ๋ณ๋๋ก ์์ฑํ์ง ์๊ณ (์ ์ํ์ง ์๊ณ ) ํจ์๋ฅผ ์์ฑํ ์ ์๋ค.
๊ดํธ ์์ ํจ์์์ ์ฌ์ฉํ ๋ณ์๋ฅผ ์ ์ํ๊ณ , ์ด์ด์ ํจ์ ์์ ์์ฑํ๋ค.
h = @(arglist)anonymous_function
Example)
sqr = @(x) x.^2;
y = sqr(4)
> y = 16
๋ฐ์ํ