matlab coder generation mex verification failed?

조회 수: 1 (최근 30일)
cui,xingxing
cui,xingxing 2022년 3월 19일
답변: Matan Silver 2022년 4월 14일
When I use matlab coder app to generate C code from my matlab code, I first start to verify if mex is runnable, but this step directly reported an error failure, according to the prompt I do not know how to modify, I am sure edgeIJ(:,1) is a single non-empty column vector of length at least 2, the matlab code runs without problems, please ask how to modify Thanks!
See attachment for additional code

채택된 답변

Matan Silver
Matan Silver 2022년 4월 14일
Hello,
I believe we can see the problem if we run myFun normally in MATLAB and set a breakpoint on line 88. We will see that the output of the call to mink is:
K>> [aa,bb]=mink(edgeIJ(:,1),2)
aa =
171
173
bb =
3
1
however, idxs, which is receiving the second output of mink, is 1x2, not 2x1:
K>> idxs
idxs =
3 4
So in this case, MATLAB Coder is complaining about assigning a 2x1 value into a 1x2 variable. You could perhaps fix this by storing the second output in an intermediate variable, and assigning it to idxs after transposing:
[minRows,idxs_untransposed] = mink(edgeIJ(:,1),2);
idxs=idxs_untransposed';
When I run "check for issues" on your example after making this change, "check for issues" passes. However, I'm not sure if this is actually what you want to do in your algorithm, so please check to make sure it is doing the right thing.
Matan

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by