How to use sinc function
조회 수: 54 (최근 30일)
이전 댓글 표시
Ricardo Uziel Rosales Ibañez
2020년 6월 4일
답변: David Goodmanson
2022년 11월 23일
I am getting an error that reads, "Check for missing argument or incorrect argument data type in call to function 'sinc' ". I am trying to implement this piecewise function, for designing FIR filter using the Fourier series method. This is what I am doing:
omegac = 0.3*pi; % Cutoff frequency
L = 50; % Filter order L = 61
M = (L-1)/2; % M
l = 0:2*M; % Coefficient index l
h = omegac/pi*sinc(omegac*(l-M)/pi); % Compute coefficients
omega = -pi:2*pi/200:pi; % Frequency range
Hd = freqz(h,1,omega); % Frequency response
plot((omega/pi),abs(Hd)),... % Use normalized frequency
xlabel('Normalized frequency'), ylabel('Magnitude'), grid;
axis([-1 1 0 1.2]);
댓글 수: 2
Walter Roberson
2020년 6월 4일
Is the problem only showing up when you use MATLAB Coder, or is it happening in basic MATLAB as well?
Your posted code works for me.
Could you confirm that you have Signal Processing Toolbox installed and licensed?
채택된 답변
David Goodmanson
2022년 11월 23일
Hi Ricardo,
while it might be nice to have the Signal Processing toolbox, you certainly don't need to buy any toolboxes to do this, same with other simple functions that happen to be squirreled away in one toolbox or another. One of the good things about Matlab is you can make your own function and save it somewhere on your path.
function y = sincc(x)
% sinc function, sin(pi*x)/(pi*x)
% y = sincc(x)
y = sin(pi*x)./(pi*x);
y(isnan(y)) = 1;
Here I just called it sincc so that it would not conflict with the Matlab function. No error checking or anything, but if you own the function you can decide how much of that is appropriate.
댓글 수: 0
추가 답변 (1개)
Ayush Goyal
2020년 6월 18일
From my understanding of the question you are trying to use the sinc function but getting error while calling it. To use the sinc function you must have licensed and installed the Signal Processing Toolbox. To check all the installed toolboxes in MATLAB you can use command “ver”. In case you don’t find the Signal Processing Toolbox installed you can refer to the following link to install the toolbox:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!