Error with sinc command

7 ビュー (過去 30 日間)
Robert Madonna
Robert Madonna 2022 年 7 月 11 日
回答済み: John D'Errico 2022 年 7 月 11 日
I have enclosed the code I used, and matlab returns the error "Check for incorrect argument data type or missing argument in call to function 'sinc'."
I tried the code in Octave online and it works flawlessly. Is there a problem with my Matlab code or some error I'm not seeing?
t = linspace(-5,5,100);
X = sinc(t);
y = fft(X);
mag = abs(fftshift(y));
f = linspace(0,100);
figure(1)
plot(t,X)
title('Figure 1')
figure(2)
plot(f,mag)
title('Figure 2')
Check for incorrect argument data type or missing argument in call to function 'sinc'.
  3 件のコメント
Torsten
Torsten 2022 年 7 月 11 日
編集済み: Torsten 2022 年 7 月 11 日
Isn't it ridiculous that one must licence a toolbox to have access to such a simple function ?
Of course, it's easy to program it on ones own, but nevertheless ...
Robert Madonna
Robert Madonna 2022 年 7 月 11 日
Thank you. I have a license for that, but it did not install in my student version. After I got it installed it worked perfectly.

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

回答 (1 件)

John D'Errico
John D'Errico 2022 年 7 月 11 日
sinc is also present in the symbolic toolbox, though it would not be of use here. You need the signal processing toolbox for the code you wrote to work.
which sinc -all
/MATLAB/toolbox/signal/signal/sinc.m /MATLAB/toolbox/signal/signal/@tall/sinc.m % Shadowed tall method /MATLAB/toolbox/symbolic/symbolic/@sym/sinc.m % Shadowed sym method
However, the error message you got is not the one I expect to see for a missing function. For example, if I do this:
t = 1:5;
hwrthwrhwyh(t)
Unrecognized function or variable 'hwrthwrhwyh'.
where there is no function of that name in MATLAB, it will throw an error, but not the one you got. But if you have ONLY the symbolic toolbox and NOT the signal processing toolbox, as is my case) then you will get this error:
sinc(1:5)
Check for incorrect argument data type or missing argument in call to function 'sinc'.
And that is the error message you got. That leads me to suspect that you lack the signal processing TB, and do have the symbolic TB.
So if you want that code to work in MATLAB, you need to buy the signal processing toolbox.

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by