数字波形产生:近似正弦波

 时间:2024-10-14 11:41:18

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); gridtitle('Difference between direct look-up and reference signal');subplot(3,1,2), plot(tonegenOut.time, tonegenOut.signals(2).values); gridtitle('Difference between interpolated look-up and reference signal');subplot(3,1,3), plot(tonegenOut.time, tonegenOut.signals(3).values); gridtitle('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所示。

数字波形产生:近似正弦波

12、使用预先配置的正弦波块命令行键入:open_system('sldemo_tonegen娄多骋能_fixpt');set_param('sldemo_tonegen_fixpt媪青怍牙', 'StopFcn','');sim('sldemo_tonegen_fixpt');figure('Color',[1,1,1]);subplot(3,1,1), plot(tonegenOut.time, tonegenOut.signals(1).values); gridtitle('Difference between direct look-up and reference signal');subplot(3,1,2), plot(tonegenOut.time, tonegenOut.signals(2).values); gridtitle('Difference between interpolated look-up and reference signal');subplot(3,1,3), plot(tonegenOut.time, tonegenOut.signals(3).values); gridtitle('Difference between CORDIC sine and reference signal');

13、如图7、8所示。

数字波形产生:近似正弦波
数字波形产生:近似正弦波

14、带时钟输入的正弦函数的使用命令行键入:subplot(1,1,1), plot(tonegenOut.time, tonegenOut.signals(4).values); gridtitle('Difference between time based sin() and reference signal');

15、如图9所示。

数字波形产生:近似正弦波

16、直接查找和线性插值的行为综述命令行键入:figure('Color',[1,1,1])tic, sldemo_sweeptable_thd(24, 256), toc

17、如图10所示。

数字波形产生:近似正弦波
  • 如何使用示波器的外部触发EXT TRIG
  • 怎么使用Arduino IDE的串口监视器
  • 立创EDA如何进行简单的电路仿真
  • 放大倍数与增益db换算公式是什么
  • 四位数码管怎么接线
  • 热门搜索
    环保小卫士手抄报 弟子规手抄报 手抄报大全简单又漂亮 六一手抄报 圣诞节手抄报 文明交通手抄报 防灾减灾的手抄报 森林草原防火手抄报 春天的手抄报图片 防溺水手抄报图片