Skip to content

Commit b010bf5

Browse files
committed
DT unit step
1 parent a80d208 commit b010bf5

2 files changed

Lines changed: 101 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Signal Processing
2-
1) Delta function and its **sifting property**.
2+
1) Discrete-time **unit impulse** function and its **sifting property**.
3+
2) Discrete-time **unit step** function and its relation to *unit impulse*.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"id": "129f0ca7",
7+
"metadata": {},
8+
"source": [
9+
"### Signal Processing\n",
10+
"#### unit impulse from the difference of two unit steps:\n",
11+
"$\\delta[n]=u[n]-u[n-1]$\n",
12+
"<hr>\n",
13+
"https://github.com/ostad-ai/Signal-Processing\n",
14+
"<br> Explanation: https://www.pinterest.com/HamedShahHosseini/Signal-Processing"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 12,
20+
"id": "1dda9e30",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"def delta(n):\n",
25+
" if n==0:\n",
26+
" return 1\n",
27+
" else:\n",
28+
" return 0\n",
29+
" \n",
30+
"def step(n):\n",
31+
" if n<0:\n",
32+
" return 0\n",
33+
" else:\n",
34+
" return 1\n",
35+
" \n",
36+
"def delta_from_step(n):\n",
37+
" return step(n)-step(n-1)"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 26,
43+
"id": "1ce18754",
44+
"metadata": {},
45+
"outputs": [
46+
{
47+
"name": "stdout",
48+
"output_type": "stream",
49+
"text": [
50+
"delta[n] u[n]-u[n-1] n\n",
51+
"0 0 -2\n",
52+
"0 0 -1\n",
53+
"1 1 0\n",
54+
"0 0 1\n",
55+
"0 0 2\n",
56+
"0 0 3\n"
57+
]
58+
}
59+
],
60+
"source": [
61+
"# consider x[n] as a sequence below\n",
62+
"# and check property delta[n]=u[n]-u[n-1]\n",
63+
"x=[-2,-1,0,1,2,3]\n",
64+
"print('delta[n] ','u[n]-u[n-1]',' n')\n",
65+
"for n in x:\n",
66+
" print(delta(n),11*' ',delta_from_step(n),5*' ',n)"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": null,
72+
"id": "c6054ddb",
73+
"metadata": {},
74+
"outputs": [],
75+
"source": []
76+
}
77+
],
78+
"metadata": {
79+
"kernelspec": {
80+
"display_name": "Python 3 (ipykernel)",
81+
"language": "python",
82+
"name": "python3"
83+
},
84+
"language_info": {
85+
"codemirror_mode": {
86+
"name": "ipython",
87+
"version": 3
88+
},
89+
"file_extension": ".py",
90+
"mimetype": "text/x-python",
91+
"name": "python",
92+
"nbconvert_exporter": "python",
93+
"pygments_lexer": "ipython3",
94+
"version": "3.8.10"
95+
}
96+
},
97+
"nbformat": 4,
98+
"nbformat_minor": 5
99+
}

0 commit comments

Comments
 (0)