Matlab 高手请进!!!

2024-11-15 10:59:04
推荐回答(3个)
回答1:

先建立M-file
function [Xk]=dft(xn,N)
%Computes Discrete fouriwe transform
%----------------------------------
%[Xk]=dft(xn,N)
%Xk=DFT coeff. array over 0<=k<=N-1
%xn=N-point finite-duration sequence
%N=length of DFT
%
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
Xk=xn*WNnk;

再在command window中输入
>> n=0:1:13;
>> N=14;
>> T=2/14.*n;
>> x=1-cos(pi*T)+2*sin(2*pi*T)+cos(3*pi*T);
>> X=dft(x,N);
>> magX=abs(X),phaX=angle(X)*180/pi

计算的结果
magX =

Columns 1 through 7

14.0000 7.0000 14.0000 7.0000 0.0000 0.0000 0.0000

Columns 8 through 14

0.0000 0.0000 0.0000 0.0000 7.0000 14.0000 7.0000

phaX =

Columns 1 through 7

0 180.0000 -90.0000 -0.0000 44.2152 141.5463 -84.4725

Columns 8 through 14

4.9331 68.1986 -96.5819 -18.1219 0.0000 90.0000 -1

回答2:

你需要的是哪方面的?我知道的是电气工程方面的MATLAB 的应用,可以不?

回答3:

我加你了,不知道你的问题我能否解决。请确定验证