assigning to vectors within bsxfun

I do not know why this operation throws an error in bsxfun
c3 = bsxfun(@(x,y,z,m,op) x(1:y(:),:) = z(1:op:op*y(:),1) + m(:), X, Y, Z, M, Option);
The loop I am trying to vectorize is this :
for k=1:Count
X(1:Y(k),k)= Z(1: Option: Option* Y(k),1) + M(k);
end
what am I doing wrong?

댓글 수: 1

Jan
Jan 2013년 4월 17일
I'm interested in a comparison of the runtimes. I do not see a benefit for the vectorized versions at first glance.

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 4월 16일
편집: Andrei Bobrov 2013년 4월 16일

1 개 추천

Z1 = bsxfun(@plus,Z(1:op:op*max(Y)),M(:).');
s = size(Z1);
Z2 = zeros(s);
Z2(sub2ind(s,Y,1:s(2))) = 1;
x = Z1.*flipud(cumsum(flipud(Z2)));

카테고리

도움말 센터File Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

질문:

2013년 4월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by