Matlab Coder : Size Mismatch Issue

조회 수: 32 (최근 30일)
Harshit
Harshit 2013년 4월 5일
편집: Walter Roberson 2019년 12월 4일
Hi,
I am using MATLAB coder to generate mex files for the matlab. Here is one error I am getting in line
x2_est_sym = x2_est_sym.';
Size mismatch (size [64 x 1] ~= size [:? x 64]).
The size to the left is the size of the left-hand side of the assignment.
Any idea.
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 12월 4일
You should create a new Question for that.

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

답변 (2개)

Arnab De
Arnab De 2013년 4월 11일
As C is statically typed, MATLAB Coder needs to compute a static type for all variables in the program, which also involves computation of the size. MATLAB Coder sets the size of a variable when it is first used. As the variable x2_est_sym is used in the right hand side and its size at that point is (presumably) [64x1], its size is set to that value. The size of the expression x2_est_sym' is however [:?x64]. When you try to assign it back to x2_est_sym, there is a size mismatch.
It is hard to suggest a fix without looking at more of your code, but can you just use a different variable on the left hand side?
  댓글 수: 2
Harshit
Harshit 2013년 4월 12일
No Arnab, it was still not resolving the issue. My friend did a small little trick and it worked x2_est_sym = (x2_est_sym).'; . He just used a bracket and it was fine.
Arnab De
Arnab De 2013년 4월 19일
Hi Harshit, Can you please post a small code snippet that exhibits the behaviour you mentioned, i.e. gives an compiler error that disappears once you use the bracket? Also, please tell me the version of MATLAB you are using. It will be most helpful.

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


Shubhashree Bal
Shubhashree Bal 2018년 1월 31일
편집: Walter Roberson 2019년 12월 4일
There is a documentation in mathswork that give the answer to this question. The link is attached below:

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by