matlab coder generation mex verification failed?

1 vue (au cours des 30 derniers jours)
cui,xingxing
cui,xingxing le 19 Mar 2022
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

Réponse acceptée

Matan Silver
Matan Silver le 14 Avr 2022
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

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by