필터 지우기
필터 지우기

adding matrix to every column in other matrix

조회 수: 1 (최근 30일)
Ahmed almansory
Ahmed almansory 2013년 4월 14일
hi all i have two matrix a 16x1024 and b 16x1 how i can adding b to every column in a ? thanks

채택된 답변

Cedric
Cedric 2013년 4월 14일
편집: Cedric 2013년 4월 14일
b_ext = repmat(b, 1, size(a, 2)) ;
c = a + b_ext ;

추가 답변 (1개)

James Tursa
James Tursa 2013년 4월 14일
bsxfun(@plus,a,b)
  댓글 수: 2
Cedric
Cedric 2013년 4월 14일
편집: Cedric 2013년 4월 14일
+1
I don't understand why it is slower than REPMAT though in cases where size(a,2) is not too large .. I thought that it would kill repmat when I tested.
James Tursa
James Tursa 2013년 4월 14일
I haven't tested bsxfun much, but I am not surprised by the timing. I have read many accounts here for various problems and several times it has come up that explicit formulations in one way or another beat bsxfun for speed. For small problems like this one the timing is likely irrelevant anyway.

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

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by