{"id":23231276,"url":"https://github.com/youssef-ashraf71/analog-filters","last_synced_at":"2025-04-05T19:25:21.534Z","repository":{"id":147851267,"uuid":"498785098","full_name":"Youssef-Ashraf71/Analog-Filters","owner":"Youssef-Ashraf71","description":"A repository for signals course tasks using Matlab","archived":false,"fork":false,"pushed_at":"2022-06-02T00:15:22.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T17:16:55.191Z","etag":null,"topics":["low-pass-filters","matlab","transfer-function"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Youssef-Ashraf71.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-01T15:07:38.000Z","updated_at":"2023-08-27T21:28:33.000Z","dependencies_parsed_at":"2023-05-27T17:15:14.409Z","dependency_job_id":null,"html_url":"https://github.com/Youssef-Ashraf71/Analog-Filters","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youssef-Ashraf71%2FAnalog-Filters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youssef-Ashraf71%2FAnalog-Filters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youssef-Ashraf71%2FAnalog-Filters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Youssef-Ashraf71%2FAnalog-Filters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Youssef-Ashraf71","download_url":"https://codeload.github.com/Youssef-Ashraf71/Analog-Filters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247388447,"owners_count":20931031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["low-pass-filters","matlab","transfer-function"],"created_at":"2024-12-19T02:14:09.833Z","updated_at":"2025-04-05T19:25:21.492Z","avatar_url":"https://github.com/Youssef-Ashraf71.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bio-Signals Tasks\n## Contributors \u003ca name = \"Contributors\"\u003e\u003c/a\u003e\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n    \u003ca href=\"https://github.com/Youssef-Ashraf71\" target=\"_black\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/83988379?v=4\" width=\"150px;\" alt=\"Youssef Ashraf\"/\u003e\n    \u003cbr /\u003e\n    \u003csub\u003e\u003cb\u003eYoussef Ashraf\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\n    \u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n    \u003ca href=\"https://github.com/Maskuerade\" target=\"_black\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/106713214?v=4\" width=\"150px;\" alt=\"Maskuerade\"/\u003e\n    \u003cbr /\u003e\n    \u003csub\u003e\u003cb\u003eMariam Ahmed\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\n    \u003c/td\u003e\n      \u003c/tr\u003e\n \u003c/table\u003e\n \n \n# Main Points :\n* The magnitude and phase characteristics of the 3-pole Butterworth low-pass filter\n* Low Pass to Low pass Filters\n* Low Pass to Band Pass Filters \n* Low Pass to Band Elimination Filters\n\n\n## Task 1 Q1 :\n```\n Use the MATLAB bode function to plot the magnitude and phase\n characteristics of the 3-pole Butterworth low-pass filter with unity gain and\n normalized frequency at ω = 1 rad/sec. Print your code, results and figures.\n```\n## Solution :\nUsing the general rule at k=3  :\n![image](https://user-images.githubusercontent.com/83988379/171443473-473cec44-0c7e-4d5d-80fb-ebfadc81ed0d.png)\n\n\n\n\n\n\n\n```\n\u003e\u003e % it is a 3-pole Butterworth low-pass filter\n\u003e\u003e % thus k=3 \u003e\u003e for the G(s) \n\u003e\u003e \n\u003e\u003e % Parameters : W = 1 rad/sec , b0=1 , a0=1 , a1=2 , a2=1 , a3=1 \n\u003e\u003e % let us Create 2 vectors carrying the coefficents of  bn and an \u003e\u003e b \u0026 a Respectively \n\u003e\u003e b = [0 0 0 1]\n\nb =\n\n     0     0     0     1\n\n\u003e\u003e a = [ 1 2 2 1 ]\n\na =\n\n     1     2     2     1\n\n\u003e\u003e % now send them to bode to start plotting magnitude and phase where W =1 rad/sec \n\u003e\u003e bode(b,a) \n\u003e\u003e % to add grid lines we will use Grid Command where grid on displays the major grid lines for the current axes\n\u003e\u003e grid\n\u003e\u003e \n```\n\n![task 1 fig 1](https://user-images.githubusercontent.com/83988379/171441113-39867627-dd73-4f84-8a23-91125f3c5754.PNG)\n\n\n\n## Task 1 Q2 :\n\n```\n Use the MATLAB buttap and lp2lp functions to find the transfer function\n of a third-order Butterworth low-pass filter with cutoff frequency fc =\n 2KHz. Then, plot its frequency response. Print your code, results and figures.\n```\n\n## Solution :\n```\n% it is a 3-pole Butterworth low-pass filter with cut off freq fc=2KHz \n[zeros , poles , k] = buttap(3);\n% calcuate coeffecients of b(numerator) and a (denominator)\n[b,a] = zp2tf ( zeros, poles , k);\n% range the frequency and convert it to rad/sec(angular)\nfreq = 1000:30:10000;\nw = 2*pi*freq;\n% declare cutoff frequency and convert it to rad/sec(angular)\nfreqc = 2*1000 ;  % we multiplied by 1000 to convert kHZ to HZ\nwc = 2*pi*freqc; \n% here calculate the new coefficents after low pass to low pass filter \n% let their names bnew , anew\n% for explaination we are converting from analog values to angular domain \n[ bnew , anew ] = lp2lp(b , a, wc); \n% lets calculate The transfer function of the  new filtered  \nGofs = freqs(bnew , anew , w);\nsemilogx(w, abs(Gofs));      % plot it \n% add grid lines\ngrid;\nhold on ;\ntitle('Frequency respone plot for 3rd-order Butterworth low-pass filter with fc = 2KHz');\nxlabel('Angular Frequency in :(rad/sec)');\nylabel('Magnitude of the Transfer Function in (dB) ');\n\n```\n![Task 2 plot](https://user-images.githubusercontent.com/83988379/171485553-18cf6afb-92b9-4529-9309-0e0f72fb8358.png)\n\n\n\n## Task 2 Q1 :\n```\nUse the MATLAB functions buttap and lp2bp to find the transfer function\nof a 3-pole Butterworth analog band-pass filter with the pass band\nfrequency centered at f0 = 4 KHz, and bandwidth BW = 2 KHz. Then, plot\nits frequency response. Print your code, results and figures.\n\n```\n\n## Solution :\n```\n% it is a 3-pole Butterworth low-pass filter with pass band freq fo=4KHz , bandwidth = 2KHZ \n[zeros , poles , k] = buttap(3);\n% calcuate coeffecients of b(numerator) and a (denominator) of the filter\n[b,a] = zp2tf ( zeros, poles , k);\n% declare band pass frequency f0=4KHZ and convert it to rad/sec(angular)\nfreq = 100:100:100000;\nfreqc = 4000 ;  \nwc = 2*pi*freqc ;\n% declare bandwidth frequency bwf= 2KHZ and convert it to rad/sec(angular)\nbwf = 2000; \nwband = 2*pi*bwf ;  \n% here calculate the new coefficents after low pass to band pass filter \n% let their names bnew , anew\n% for explaination we are converting from analog values to angular domain \n[ bnew , anew ] = lp2bp(b , a, wc , wband ); \n% lets calculate the transfer function of the band-pass filter\nw =2*pi*freq ; \nGofs = freqs(bnew , anew , w);\nsemilogx(freq, abs(Gofs));      % plot freq response in hertz\n% add grid lines\ngrid;\nhold on;\ntitle('Frequency respone plot for 3rd-order Butterworth band-pass filter with fo=4kHZ , Bw = 2KHZ');\nxlabel('Frequency in :(HZ)');\nylabel('Magnitude of the Transfer Function in (dB)');\n\n```\n\n![Task 3 plot](https://user-images.githubusercontent.com/83988379/171520435-d220aae0-c9b1-4a24-9f2e-058bbd55e52b.png)\n\n\n\n## Task 2 Q2 :\n```\nUse the MATLAB functions buttap and lp2bs to find the transfer function of\na 3-pole Butterworth band-elimination (band-stop) filter with the stop band frequency\ncentered at f0 = 5 KHz, and bandwidth BW = 2 KHz. Then, plot its frequency response.\nPrint your code, results and figures.\n```\n\n## Solution :\n```\n % it is a 3-pole Butterworth with stop band frequency centered at f0 = 5 KHz , and bandwidth BW = 2 KHz\n\n [zeros , poles , k] = buttap(3);\n % calcuate coeffecients of b(numerator) and a (denominator)\n [b,a] = zp2tf ( zeros, poles , k); \n % declare band pass frequency f0=5KHZ and convert it to rad/sec(angular)\n freq = 100:100:100000;\n freqc = 5000 ; \n wc = 2*pi*freqc ; \n % declare bandwidth frequency bwf= 2KHZ and convert it to rad/sec(angular)\n bwf = 2000; \n wband = 2*pi*bwf ;  \n % here calculate the new coefficents after low pass to stop pass filter\n\n % let their names bnew , anew\n % for explaination we are converting from analog values to angular domain \n [ bnew , anew ] = lp2bs(b , a, wc , wband ); \n % lets calculate the transfer function of the stop-pass filter\n w =2*pi*freq ; \n Gofs = freqs(bnew , anew , w);\n semilogx(freq, abs(Gofs));      % plot freq response in hertz\n % add grid lines\n grid;\n hold on;\n title('Frequency respone plot for 3rd-order Butterworth band-elimination filter with fo=5kHZ , Bw = 2KHZ');\n xlabel('Frequency in :(HZ)');\n ylabel('Magnitude of the Transfer Function in (dB)');\n\n```\n![task 4 plot final](https://user-images.githubusercontent.com/83988379/171520460-6b1cfc6b-ffe8-4ab0-92af-8e5c378a6e43.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoussef-ashraf71%2Fanalog-filters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoussef-ashraf71%2Fanalog-filters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoussef-ashraf71%2Fanalog-filters/lists"}