how to write delta function like this?

26 views (last 30 days)
Kuheli Mondal
Kuheli Mondal on 31 Mar 2016
Answered: VBBV on 24 Nov 2021
h(n)=delta(n-3)-2*delta(n-4); delta(n==0)=1 can any one help me. Thank you.
  1 Comment
Ced on 31 Mar 2016
The delta function in this case is defined as
"if n is equal to 0, then the function value is 1, else, the function value is 0"
You can implement it just like that in matlab.

Sign in to comment.

Answers (2)

Jan on 31 Mar 2016
delta = (n==0);
  1 Comment
Ced on 31 Mar 2016
Did you mean to write
delta = @(n)(n==0);

Sign in to comment.

VBBV on 24 Nov 2021
syms n
h = @(n) dirac(n-3)-2*dirac(n-4);
h = h(0:0.1:10);
h(h==0) = 1;


Community Treasure Hunt

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

Start Hunting!