フィルターのクリア

matlab coder generation mex verification failed?

3 ビュー (過去 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 Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by