coder.ceval for printf from stdio.h
显示 更早的评论
Hello, everybody! I'd like to generate C code from an m-file which makes use of MATLAB fprintf function as follows:
fprintf('Time level %-*.*f [s], Iterations: %d\n',field_width,precision,time,iter);
Since fprintf is not supported for the code generation, nor can I use coder.extrinsic method, I turn to a question:
How to rewrite the command using coder.ceval method and the standard C library function printf? To be more specific, what should the arguments be like in coder.ceval('printf', arguments); ?
While not using field_width and precision, C code generated from the following one executes without a problem:
s1=['%s%f%s%d' 10 0];
s2=['Time level ' 0];
s3=['[s], Iterations: ' 0];
coder.ceval('printf',s1,s2,time,s3,int32(iter));
However, including the asterisks and left-justify options cause segmentation fault whenever the generated C code is compiled, built and run. Any help is appreciated!
3 个评论
Kaustubha Govind
2012-5-29
I wonder if this is a bug. Could you try contacting MathWorks Tech Support about this?
Tomas Jurena
2012-5-30
Tomas Jurena
2012-5-30
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Texas Instruments C2000 Processors 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!