帮助中心帮助中心
为定点或单精度转换创建配置对象
config_obj = coder.config('fixpt')
config_obj = coder.config('single')
示例
config_obj = coder.config('fixpt') 创建一个 coder.FixptConfig 配置对象。在将浮点 MATLAB® 代码转换为定点 MATLAB 代码时,请将此对象与 fiaccel 函数结合使用。
coder.FixptConfig
fiaccel
config_obj = coder.config('single') 创建一个 coder.SingleConfig 配置对象,以便在从双精度 MATLAB 代码生成单精度 MATLAB 代码时与 convertToSingle 函数结合使用。
coder.SingleConfig
convertToSingle
全部折叠
使用默认设置创建一个 coder.FixptConfig 对象 fixptcfg。
fixptcfg
fixptcfg = coder.config('fixpt');
设置测试平台名称。在此示例中,测试平台函数名称为 dti_test。
dti_test
fixptcfg.TestBenchName = 'dti_test';
将浮点 MATLAB 函数转换为定点 MATLAB 代码。在此示例中,MATLAB 函数名称为 dti。
dti
fiaccel -float2fixed fixptcfg dti
创建一个 coder.SingleConfig 对象 scfg。
scfg
scfg = coder.config('single');
设置测试平台名称。在此示例中,测试平台函数名称为 myfun_test。为输入和输出变量的比较绘图启用数值测试和数据记录。
myfun_test
scfg.TestBenchName = 'myfun_test'; scfg.TestNumerics = true; scfg.LogIOForComparisonPlotting = true;
将双精度 MATLAB 代码转换为单精度 MATLAB 代码。在此示例中,MATLAB 函数名称是 myfun。
myfun
convertToSingle -config scfg myfun
在 R2014b 中推出
coder.FixPtConfig | fiaccel | coder.SingleConfig | convertToSingle
coder.FixPtConfig
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office