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

58 Ansichten (letzte 30 Tage)
boutaina doudouche
boutaina doudouche am 30 Nov. 2020
Bearbeitet: David Goodmanson am 1 Dez. 2020
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)');

Antworten (2)

Ameer Hamza
Ameer Hamza am 30 Nov. 2020
Bearbeitet: Ameer Hamza am 30 Nov. 2020
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 am 1 Dez. 2020
Bearbeitet: David Goodmanson am 1 Dez. 2020
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.

Community Treasure Hunt

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

Start Hunting!

Translated by