数组可以明显慢于MATLAB中的显式循环。为什么?
arrayfun
:
T = 4000;N = 500;x = randn(T, N);Func1 = @(a) (3*a^2 + 2*a - 1);ticSoln1 = ones(T, N);for t = 1:T for n = 1:N Soln1(t, n) = Func1(x(t, n)); endendtocticSoln2 = arrayfun(Func1, x);toc
Elapsed time is 1.020689 seconds.Elapsed time is 9.248388 seconds.
arrayfun
cellfun
我的问题是:arrayfun
cellfun
注:arrayfun
编辑:Func1
编辑:feature accel off
Elapsed time is 28.183422 seconds.Elapsed time is 23.525251 seconds.
for
arrayfun
arrayfun
Func1
慕娘9325324
相关分类