MATLAB/SIMULINK生成代码错误之change the default character encoding setting


SIMULINK点击生成C代码报错

错误提示:

Error encountered while executing PostCodeGenCommand for model 'RTW_sc3': Close all block diagrams (using 'bdclose all') before trying to change the default character encoding setting

Caused by:

Close all block diagrams (using 'bdclose all') before trying to change the default character encoding setting

原因:

未设置默认编码所导致

解决方法:

在初始化中添加这两句:

currentCharacterEncoding = slCharacterEncoding();

slCharacterEncoding('Windows-1252');