matlabにおける@の意味はなんでしょうか?
Show older comments
reductionFcn = @(x)x;
上記の構文が例題にあったのですが、右辺の意味がわかりません。
matlabにおける@の意味は何でしょうか?
Accepted Answer
More Answers (1)
■reductionFcn = @(x) x;について
無名関数、通称ラムダ(LAMBDA)関数における変数の宣言です。
意味としましては、reductionFcn = @(使う変数) 関数 になります。
■何がうれしいか
よく使用される数式の関数を作成し、使いまわせることが利点です。
f = @(x,y) x + y
f(1,2)
f((1:3),5)
■その他
Fs = 100;
t = (0:1/Fs:3);
T = table2cell(table((1:3)')) % 1~3の変数をcell型にしています
スイープパラメータの設定
C = cellfun(@(x) MyFcn(t,x),T,UniformOutput=false); % cell型のxのみ使用する
まとめて図示
figure
hold on
cellfun(@(x) plot(t,x),C,UniformOutput=false)
自作関数
function y = MyFcn(t,x)
tmp = x.^2;
y = tmp.*sin(2*pi.*x.*t);
end
Categories
Find more on コマンドの入力 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
