这个例子展示了设计和评估正弦波数据表所需的一些主要步骤 , 这些数据表可用于嵌入式系统和任意波形产生仪器的数字波形合成应用 。
需要这些哦
电脑
simulink软件
方式/
1在双精度浮点中建立表
号令行键入:
N = 256;
angle = 2*pi * (0:(N-1))/N;
s = sin( angle )';
thd_ref_1 = ssinthd( s, 1, N, 1, 'direct' )
thd_ref_2p5 = ssinthd( s, 5/2, 2*N, 5, 'linear' )
cs = cordicsin( angle, 50 )';
thd_ref_1c = ssinthd(cs, 1, N, 1, 'direct' )
thd_ref_2p5c = ssinthd(cs, 5/2, 2*N, 5, 'linear' )
2如图1所示 。

3将正弦波近似应用于模子中
号令行键入:
open_system('sldemo_tonegen');
set_param('sldemo_tonegen', 'StopFcn','');
sim('sldemo_tonegen');
currentFig = figure('Color',[1,1,1]);
subplot(3,1,1), plot(tonegenOut.time, tonegenOut.signals(1).values); grid
title('Difference between direct look-up and reference signal');
subplot(3,1,2), plot(tonegenOut.time, tonegenOut.signals(2).values); grid
title('Difference between interpolated look-up and reference signal');
subplot(3,1,3), plot(tonegenOut.time, tonegenOut.signals(3).values); grid
title('Difference between CORDIC sine and reference signal');
4如图2所示 。

5【数字波形产生:近似正弦波】运行这个模子 。
如图3所示 。

6细心不雅察波形精度
号令行键入:
ax = get(currentFig,'Children');
set(ax(3),'xlim',[4.8, 5.2])
set(ax(2),'xlim',[4.8, 5.2])
set(ax(1),'xlim',[4.8, 5.2])
7如图4所示 。

8统一表 , 固定点实现
号令行键入:
bits = 24;
is = num2fixpt( s, sfrac(bits), [], 'Nearest', 'on');
thd_direct1 = ssinthd(is, 1, N, 1, 'direct')
thd_direct2 = ssinthd(is, 2, N, 2, 'direct')
thd_direct3 = ssinthd(is, 3, N, 3, 'direct')
thd_linterp_2p5 = ssinthd(is, 5/2, 2*N, 5, 'fixptlinear')
9如图5所示 。

10比力分歧表格和方式的成果
号令行键入:
thd_double_direct = ssinthd( s, 33/4, 4*N, 33, 'direct')
thd_sfrac24_direct = ssinthd(is, 33/4, 4*N, 33, 'direct')
thd_double_linear = ssinthd( s, 33/4, 4*N, 33, 'linear')
thd_sfrac24_linear = ssinthd(is, 33/4, 4*N, 33, 'fixptlinear')
11如图6所示 。
猜你喜欢
- Excel数字变为日期解决经验
- wps2019文档怎么样在数字底部批量添加下划线
- Excel从左往右提取指定个数字符串技巧
- 最新的小米8MIUI10系统怎样将电量显示成数字
- 怎么p图改数字
- 挖客 如何使用手机体验挖矿
- excel单元格数字格式怎么设置
- excel统计数字重复出现的次数
- 个人数字证书的申请和使用
- 必应输入法快速输入繁体数字技巧
