forked from mutalibcs/Digital-Signal-Processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,264 additions
and
180 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "3693637f", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1. 4. 8. 8. 3. -2. -1.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#convulation sum EX: 2.3.2\n", | ||
"#1st method\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"x = [1, 2, 3, 1]\n", | ||
"h = [1, 2, 1, -1]\n", | ||
"lx = len(x)\n", | ||
"lh = len(h)\n", | ||
"y = np.zeros(lx+lh-1)\n", | ||
"\n", | ||
"for m in range(lx):\n", | ||
" for n in range(lh):\n", | ||
" y[m+n] = y[m+n] + x[m]*h[n]\n", | ||
"print(y)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "a84b4ef8", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1 4 8 8 3 -2 -1]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#2nd method relates with 1st\n", | ||
"z = np.convolve(x, h, 'full')\n", | ||
"print(z)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "b78f4be2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1 4 8 8 3 -2 -1]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#3rd method indivitual\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"x = [1, 2, 3, 1]\n", | ||
"h = [1, 2, 1, -1]\n", | ||
"\n", | ||
"z = np.convolve(x, h, 'full')\n", | ||
"print(z)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "58064ae7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"def conv(x, h):\n", | ||
" lx = len(x)\n", | ||
" lh = len(h)\n", | ||
" y = np.zeros(lx+lh-1)\n", | ||
" \n", | ||
" for m in range(lx):\n", | ||
" for n in range(lh):\n", | ||
" y[m+n] = y[m+n] + x[m]*h[n]\n", | ||
" return y\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1. 4. 8. 8. 3. -2. -1.]\n", | ||
"[ 2. 8. 18. 22. 16. 4. 0.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"x = [1,2,3,1]\n", | ||
"h = [1, 2, 1, -1]\n", | ||
"\n", | ||
"y = conv(x, h)\n", | ||
"print(y)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"yd2 = conv(x, h) + conv(x, h2)\n", | ||
"print(yd2)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[1. 2. 3. 1.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"d = np.zeros(1)\n", | ||
"d[0] = 1\n", | ||
"\n", | ||
"#identity law\n", | ||
"yi = conv(x, d)\n", | ||
"print(yi)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1. 4. 8. 8. 3. -2. -1.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"#communitative property\n", | ||
"yc = conv(h, x)\n", | ||
"print(yc) \n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1. 6. 19. 37. 47. 36. 12. -5. -5. -1.]\n", | ||
"[ 1. 6. 19. 37. 47. 36. 12. -5. -5. -1.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#assosiative law \n", | ||
"h2 = [1,2 ,3, 1]\n", | ||
"ya = conv(yc, h2)\n", | ||
"print(ya) \n", | ||
"yb = conv(h2, yc)\n", | ||
"print(yb)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[ 1. 4. 8. 8. 4. 2. 9. 14. 13. 6. 1.]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"\n", | ||
"#distributive law \n", | ||
"yd1 = conv(x, h + h2)\n", | ||
"print(yd1)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.