Not enough input arguments. length()

18 ビュー (過去 30 日間)
Patrick Arraki
Patrick Arraki 2021 年 5 月 22 日
回答済み: Kiran Felix Robert 2021 年 6 月 7 日
Hey,
I wrote a function that should execute a DFT. I know there is FFT, but it's a college job.I don't understand why length doesn't work for the best of me.mainly because it worked without any problems in previous functions.
Could someone tell me what I'm doing wrong?
I googled and only found solutions to problems caused by misspellings.
Here is my code:
function[S] = DFT(s)
N = length(s); %<- thats what the error caused
X = 1:N;
for m = 1 : N
for k = 1 : N
X(m) = X(m) + s(k) * exp(-(1i*pi*2*k*m*(1/N)));
S(m) = X(m);
end
end
end
  2 件のコメント
Les Beckham
Les Beckham 2021 年 5 月 22 日
How did you call the function? You can't just press the Run button. You need to provide the input data.
per isakson
per isakson 2021 年 5 月 22 日
編集済み: per isakson 2021 年 5 月 22 日
How did you call the DFT ? What was the value of s ?

サインインしてコメントする。

回答 (1 件)

Kiran Felix Robert
Kiran Felix Robert 2021 年 6 月 7 日
Hi Partick,
Check the input argument when you call the DFT Function.
When you call from the command-line, provide sufficient input arguments.
On the Run button, use the extra options (type code to run) and provide proper input arguments to the function.
Try using a break point just after calling the function to debug the input argument data type.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by