1

I want to do the following:

for i = 1:N
    l(i) = mvncdf(x(i,:), mu, sigma(:,:,i))
end

Can I do it without a loop given that a covariance matrix is different for each row of x?

4

1 回答 1

0

当然。尝试这个:

func = @(i) mvncdf(x(i,:), mu, sigma(:,:,i));
l = arrayfun(func, 1:N)

这是一个简洁的谜题类型的问题,但我想说你的带有循环的代码更具可读性,并且可能同样快。

于 2013-02-08T17:39:55.113 回答