How Define Delta Function
조회 수: 178 (최근 30일)
이전 댓글 표시
I have a problem about calculating with Delta Function. I am trying write matlab code for these function.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/561038/image.png)
I wrote the following code for this function.
n = -5:1:7;
x = delta(n+1) - delta(n) + unit(n+1) - unit(n-2);
stem(n,x,'fill');
axis([-6 8 -1.5 1.5])
xlabel('n')
ylabel('x[n]')
grid
But I am getting the following error.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/561043/image.png)
I don't now how can ı write the delta function in this way ,
function y = unit(x);
y = zeros(size(x));
y(x>0) = 1;
end
Can you help me write the delta function as the 'unit' function you see above? Thank you for your helping.
댓글 수: 0
채택된 답변
Star Strider
2021년 3월 24일
If you have the Symbolic Math Toolbox, use the dirac function. It can be used with non-symbolic arguments as well.
댓글 수: 4
Walter Roberson
2021년 3월 24일
That is not a true Dirac δ function.
delta = @(x) x==0;
unit = @(x) x>=0;
n = -5:1:7;
x = delta(n+1) - delta(n) + unit(n+1) - unit(n-2);
stem(n,x,'fill');
axis([-6 8 -1.5 2])
xlabel('n')
ylabel('x[n]')
grid
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Bartlett에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!