MATLAB Answers

Coder - Subtract vector from matrix, size mismatch error

조회 수: 12(최근 30일)
amin ya
amin ya 28 Apr 2019
편집: amin ya 12 Jun 2019
Although MATLAB supports subtracting a vector from a matrix (as stated here : https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html ), when I try to generate code using MATLAB coder it gives me size mismatch error.
For example for the following function MATLAB can't generate code:
function C=subtraction()
A=3*ones(4,5);
B=ones(1,5);
C=A-B;
end
What should I do?

  댓글 수: 0

로그인 to comment.

채택된 답변

Walter Roberson
Walter Roberson 28 Apr 2019
specifically says that implicit expansion is not supported by Coder at this time.
The option is to use
C = bsxfun(@minus, A, B);

  댓글 수: 0

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by