Undefined function 'sinc' for input arguments of type 'double'.

64 次查看(过去 30 天)
Hello everyone,
i have an error in MATLAB that i can't found a solution ,please help if you can
there is my code :
Nt=21;
N=(Nt-1)/2;
n=-N:1:N;
h=(1/3)*sinc(n/3);
subplot(3,1,1),
stem(n,h);
title('nT=21,Reponse impulsionnelle')
xlabel('n');
ylabel('h');
[H,w]=freqz(h,1,256);
subplot(3,1,2);
plot((w/2*pi),abs(H));
title('gain')
xlabel('frequence');
ylabel('abs(H)')
subplot(3,1,3);
plot((w/2*pi),angle(H));
title('phase');
xlabel('frequence');
ylabel('angle(H)');

回答(2 个)

Ameer Hamza
Ameer Hamza 2020-11-30
编辑:Ameer Hamza 2020-11-30
sinc() is available in the Signal processing toolbox or the Symbolic Toolbox. You can check of you have the toolbox installed by running the following in the command window
ver signal % for signal processing toolbox
ver symbolic % for symbolic toolbox
If you get a warning, it means that you don't have the toolbox.

David Goodmanson
David Goodmanson 2020-12-1
编辑:David Goodmanson 2020-12-1
Hi boutaina,
Since it's easy in Matlab to make your own functions, you don't need toolboxes that are (probably not intentionally, but still) sequestering simple mathematical functions that should be available to one and all in the core product. Just store the function somewhere on your Matlabpath.
function y = sincc(x)
% normalized sinc function, sin(pi*x)/(pi*x), no checks on the input
%
% y = sincc(x)
y = sin(pi*x)./(pi*x);
y(x==0) = 1;
end
This function could be called sinc, but when making an alternative version of functions that Matlab has, I tend to use a name such as sincc so as to not conflict with the Matlab name. Then if you were to get one of the toolboxes there will not be a question about which function is being used.
Note that a second common definition for sinc is the so-called unnormalized version sin(x)/x. In your context, the normalized definition is probably the right one.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by