当前位置:编程学习 > Matlab >>

求matlab编程实现DDS的各个模块产生正弦波,不用simulink做,直接是matlab实现的,364660990@qq.com

急用,收到能用的再加分
追问:你好,请问下,DDS原理上的相位累加器是哪段程序?刚开始学不是很懂,还有就是那个k=floor(fout/Fs*2^Bits); 
index=0; 这是什么意思。麻烦了!谢谢
答案:function [y,t]=dds_matlab(fout,Fs,Bits,endtime) 
% DDS_MATLAB function to generate the DDS sine wave 
% in MATLAB language; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%   [y,t]=dds_matlab(fout,Fs,Bits,endtime)        % 
%   fout      :   Output frequency                %   
%   Fs        :   Sample frequency                %   
%   Bits      :   Number of bits of the LUT       %   
%   endtime   :   Expected simulation endtime     %   
%   y         :   Output sine wave                % 
%   t         :   Output time                     %   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
% Output some infomation 
delta_F=Fs/2^Bits; 
disp(['The frequency resolution of this DDS is:'... 
    ,num2str(delta_F),'Hz']); 
disp(['Output frequencies are:0Hz,',num2str(delta_F),'Hz,'... 
    num2str(2*delta_F),'Hz,......,',num2str(Fs/2),'Hz']); 
% Construct the Sine Wave LUT store in array LUT 
t=2*pi*(0:2^Bits-1)/2^Bits; 
LUT=sin(t); 
 
t=0:1/Fs:endtime; 
N=length(t); 
n=1; 
y=zeros(1,N); 
IND=zeros(1,N); 
% Input Frequency Word 
k=floor(fout/Fs*2^Bits); 
index=0; 
 
while n<=N 
    IND(n)=index; 
    index=index+k; 
    index=mod(index,2^Bits); 
    n=n+1; 
end 
IND=IND+1; 
y=LUT(IND); 
plot(t,y); 
figure(1); 
axis([0 endtime -1.2 1.2]); 
grid on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> [y,t]=dds_matlab(10,100,10,0.5);
The frequency resolution of this DDS is:0.097656Hz
Output frequencies are:0Hz,0.097656Hz,0.19531Hz,......,50Hz

上一个:急!!!关于matlab程序的,两个应该出来的差不多的,结果不是,帮忙看下哪里错了
下一个:请问下图的函数中,xi有一个取值范围,对应Di有一个值,那怎么在matlab中的目标函数中描述出来

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,