Simple use of bsxfun

I am having trouble doing simple vectorization operations for GPU using bsxfun and arrayfun.
For example, How would I do this operation on a GPU :
X(X>num)=num
I tried :
X = bsxfun(@gt, X, num)
Then I am stuck at the assignment. I am guessing the ternary operations are not possible?
Thank you so much for helping out.

 채택된 답변

Jan
Jan 2013년 4월 12일
편집: Jan 2013년 4월 12일

4 개 추천

Tjhere is no reason to use bsxfun here, because X(X > num) = num is sufficient already. An alternative:
X = min(X, num);
bsxfun is useful, when an elementwise operation between a matrix and a vector should be performed and the vector needs to be "inflated" for this.

추가 답변 (0개)

카테고리

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

질문:

2013년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by