赞
踩
不考虑频率分辨率、量化噪声,仅为验证之用
clc;clear all;close all; %-- 生成DDS_ROM N = 16384; sin_rom = zeros(1,N); cos_rom = zeros(1,N); for m=0:N-1 sin_rom(1,m+1) = sin(m/N*2*pi); cos_rom(1,m+1) = sin(m/N*2*pi); end %-- 单路DDS输出 FS = 5000; f = 1000; freq_word = round(f/FS*N); phase_word = 0; phase = 0; single_dds_sig = zeros(1,N); for m=0:N-1 if m== 0 phase = freq_word + phase_word; else phase = freq_word + phase; end phase_addr = mod(phase,N); if phase_addr == 0 phase_addr = 1; end single_dds_sig(1,m+1) = sin_rom(1,phase_addr); end y = abs(fft(single_dds_sig)); figure; plot(20*log10(y/max(y))); title('单路DDS输出'); %-- 多路DDS输出 FS = 5000; f = 1000; NUM = 16; freq_word = NUM*round(f/FS*N); phase_word = linspace(0,NUM-1,NUM)*round(f/FS*N); phase = -linspace(1,NUM,NUM)*round(f/FS*N); multi_dds_sig = zeros(NUM,N/NUM); for m=1:NUM for k=0:N/NUM-1 if k==0 phase(1,m) = freq_word + phase_word(1,m); else phase(1,m) = freq_word + phase(1,m); end phase_addr = mod(phase(1,m),N); if phase_addr == 0 phase_addr = 1; end multi_dds_sig(m,k+1) = sin_rom(1,phase_addr); end end multi_dds_sig_new = reshape(multi_dds_sig,1,N); y = abs(fft(multi_dds_sig_new)); figure; plot(20*log10(y/max(y))); title('多路DDS输出');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。