Is it possible to put C++ code on a .m for help MATLAB Coder to traduce ?

1 回表示 (過去 30 日間)
Michel
Michel 2011 年 8 月 1 日
Hello,
I use Matlab Coder and i use the function coder.ceval for use C++ function when i generate my C++ code.
But Matlab make a lot of error (use the value of the variable instead the name variable ...)
So i search to know if it is possible to put directly the C++ code on the .m instead use coder.ceval for have the good code C++ after the generation with Matlab Coder ?
For example : I use
If isempty(coder.target)
Texte=int2str(Variable);
else
coder.ceval(sprintf,Texte,'"%d"',Variable);
end
But Matlab Coder make some error, i would use something like this :
If isempty(coder.target)
Texte=int2str(Variable);
else
A_Function('sprintf(Texte,"%d",Variable);');
end
Do you know if somethings like that exist ? Thank you for your help.

採用された回答

Kaustubha Govind
Kaustubha Govind 2011 年 8 月 1 日
I think you need single quotes around your function name (sprintf), because the first argument to coder.ceval is the string containing the C-function that you want to call.
if isempty(coder.target)
Texte=int2str(Variable);
else
coder.ceval('sprintf',Texte,'"%d"',Variable);
end
This should generate a call to sprintf as you expect.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by