I have tried solving DFT but i am getting an error

조회 수: 3 (최근 30일)
Sam17
Sam17 2017년 9월 20일
댓글: Walter Roberson 2017년 9월 20일
Here is my code: i tried solving using matrix multiplication
f1=7;f2=21;
fs=220; %Sampling frequency f2*10
ts=1/fs; %sampling time
t=0:10-ts;
y=sin(2*pi*t*f1)+sin(2*pi*t*f2); %given data set
N=length(y);
n = 0:1:N-1; % row vector for n
k = 0:1:N-1; % row vecor for k
WN = exp(-1j*2*pi/N); % the w elements
n1= transpose(n);
nk = n1*k; % creates a N by N matrix of nk values
WNnk = WN .^ nk; % DFT matrix
Xk = WNnk.*y;
plot(n,xk)
Here is my error message:
Error using .* Matrix dimensions must agree.
Error in a21 (line 13) Xk = WNnk.*y;
Please help me plot:
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 9월 20일
At the time of your line WNnk.*y then WNnk is 10 x 10 and y is 1 x 10. What size of output were you expecting from that?
Note: your line
t=0:10-ts;
should be
t=0:ts:10-ts;

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by