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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by