"Mex file generation" invalid character code error

12 vues (au cours des 30 derniers jours)
Douglas
Douglas le 17 Juil 2015
Commenté : konmin dung le 11 Avr 2021
When I tried to convert the following code to a mex file using coder I've gotten the following error:
Caught "std::exception" Exception message is:
Invalid character code sequence detected.
CODE 1:
% Y: new data matrix
% X: training data matrix, each row is one observation, each column is one feature
% type: type of kernel, can be 'simple', 'poly', or 'gaussian'
% para: parameter for computing the 'poly' kernel, for 'simple'
% and 'gaussian' it will be ignored
% K: kernel matrix
% Copyright by Quan Wang, 2011/05/10
% Please cite: Quan Wang. Kernel Principal Component Analysis and its
% Applications in Face Recognition and Active Shape Models.
% arXiv:1207.3538 [cs.CV], 2012.
function K=kernel_NewData(Y,X,type,para) %#codegen
N=size(X,1);
if strcmp(type,'simple')
K=Y*X';
end
if strcmp(type,'poly')
K=Y*X'+1;
K=K.^para;
end
if strcmp(type,'gaussian')
K=distanceMatrix([X;Y]);
K=K(N+1:end,1:N);
K=K.^2;
K=exp(-K./(2*para.^2));
end
The above distanceMatrix() has only matrix multiplication and conditional operations.
Then, I have tested also a short code "soma.m", but the error persists:
CODE 2
function c = soma(a,b) %#codegen
c =a+b;
Does anybody knows how to solve this?
I'm working on ubuntu 14.04 with gcc/g++ 4.7.
Thanks.
  2 commentaires
Walter Roberson
Walter Roberson le 17 Juil 2015
Could you describe further how you are invoking the coder?
Ryan Livingston
Ryan Livingston le 20 Juil 2015
Do you have any non-ASCII characters in any relevant directory names? Maybe in pwd, matlabroot, or the codegen build directory?
It would likely be good to contact MathWorks Technical Support regarding this as well.

Connectez-vous pour commenter.

Réponse acceptée

Harsheel
Harsheel le 20 Juil 2015
This may occur if your MATLAB current working directory has non-ascii characters. To resolve this, remove any non-ascii character in the full path of the current working directory.
  2 commentaires
Douglas
Douglas le 20 Juil 2015
Thank you.
konmin dung
konmin dung le 11 Avr 2021
very good. thx!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by