Define a new binary operator in MATLAB?
이전 댓글 표시
Hi,
I wondered whether it is possible to define a new, binary operator in MATLAB. The thing is, I need a new operator to "multiply" two matrices in an uncommon way, like this:
A = [.5 .5 0; 0 1 0; 0 .5 .5];
B = [.5 .5 0; 0 1 0; 0 .5 .5];
RowsA = size(A,1);
ColsA = size(A,2);
RowsB = size(B,1);
ColsB = size(B,2);
C = zeros(RowsA*RowsB, ColsA*ColsB);
for i = 1:RowsA
for j = 1:ColsA
C( 1+(i-1)*RowsB:i*RowsB, 1+(j-1)*ColsB:j*ColsB ) = A(i,j) * B;
end
end
Instead of making a function and calling C = myfunction(A,B), I'd like to use C = A # B, with # the new operator (or perhaps another symbol if this is not possible).
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!