[討論] 有關於arrayfun處理struct array的問題

作者: wdw0925 (小小麥克)   2017-11-10 17:17:07
這是把struct當成array來處理的範例:
datas = repmat(struct('x', [], 'y', []), 100, 1)
for i = 1:100
numData = randsample(10:100, 1);
datas(i).x = randn(numData, 1);
datas(i).y = 1 + datas(i).x* 2 + randn(numData, 1);
end
lmModels = arrayfun(@(d) fitlm(d.y, d.x), datas, 'uni', false);
這是之前某位大神po的code 小弟想問的是最後一行
lmModels = arrayfun(@(d) fitlm(d.y, d.x), datas, 'uni', false);
是什麼意思呢? 請各位大大指教 謝謝!

Links booklink

Contact Us: admin [ a t ] ucptt.com