## Monday, January 18, 2010

### Sum of Sinusoids Triangle Approximation

Triangle Approximation: Sum of Sinusoids Example

The following Matlab code provides an example of the fact that any signal can constructed using a sum of sinusoids.

```clear all; %clear all variablesfs = 50; % sample freqTs=1/fs; % sample periodn=0:1*fs; % time window (fs=samples per second), 1 secondtn=n*Ts; % sample indexwave_1=sin(2*pi*5*tn);wave_2=sin(-1/9*sin(6*pi*5*tn));wave_3=sin(1/25*sin(10*pi*5*tn));wave_4=sin(-1/49*sin(14*pi*5*tn));wave_5=sin(1/81*sin(18*pi*5*tn));wave_6=sin(-1/121*sin(22*pi*5*tn));wave_7=sin(1/169*sin(26*pi*5*tn));x = (8/(pi^2))*(wave_1+wave_2+wave_3+wave_4+wave_5+wave_6+wave_7);% Time domain plot of x(t)=cos(2*pi*5*tn)figure('Color',[1 1 1]);h=plot(tn,wave_1,'--r',tn,wave_2,'--k',tn,x,'g','LineWidth',2);box off;hold on;xlabel('Time(s)');ylabel('Amplitude');title('Square Wave Approximation');axis([0 1 -1.5 1.5]); ```
``` Posted by Unknown at 9:15 AM ```
``` 1 comment: YATIN MEHANDIRATTA said... Why does the above code has x = ( 8 / (pi^2 ) ??????Please if you could explain, would really appreciate it.Thanks in advance,Yatin February 24, 2013 at 10:18 PM Post a Comment ```
``` ```
``` ```
``` Newer Post Older Post Home Subscribe to: Post Comments (Atom) ```
``` ```
``` ```
``` About Twitter Linkin Profile With my bikes 2008 (2008 Ninja250 & 1974 Ducati Mark3 450) Contact Info RFWarrior@yahoo.com Tech Posts: Electronics LM741 Datasheet Thick Lines in LTSpice Modeling diode breakdown in LTSpice Temp Sweeps in LTSpice - Part I Temp Sweeps in LTSpice - Part 2 Modeling LM741 Slew Rate in LTSpice Exporting LTSpice Data NE5532 LTSpice Model LM741 LTSpice Model LTSpice Introduction LM741 Datasheet VCVS Modeling in LTSpice Parameter Sweeps: .step Grading Rubric Tech Posts (DSP and Comm) Matlab Interpolation Compute Spectrum Function Foruier Additivity Plotting Normal Distributions Fourier Transform for Dummies Matlab: Random Numbers Simple FM Modulator for LTSpice Receiver Sensitivity RF Link Budget Creating a Terrain Profile DSP Tutorial #1: Basic Plots DSP Tutorial #2: Signal Creation DSP Tutorial #3: Sum of Sinusoids DSP Tutorial #4: Complex Signals DSP Tutorial #5: Frequency Analysis DSP Tutorial #6: Looping DSP Tutorial #7: Audio Processing DSP Tutorial #8: Spectrum Function DSP Tutorial #9: Basic digital filter DSP Tutorial #10: Windowing DSP Tutorial #11: Filters DSP: Sample Audio File (fp3.wav) DSP: WCDMA File (wcdma2.csv) DSP: Raw Stock Data File DSP: Obtaining Raw Stock Data DSP: Coherent Noise Averaging DSP: 3G WCDMA Windowing DSP: Noise Averaging WCDMA Technology Management Super Cruncers Book Review LP Compensation Technical Presentation Tips Effective Team Leadership Papers LP Compensation (IEEE) Mantech - Yield Mgmt. WCDMA Noise Averaging RF Shielding Considerations IS-95a Capacity Analysis Temp Controlled V_Source DTV Optimization My Groups Moto 68HC12 LTSpice 902MHz Group Excel Training Installing Solver 2007 History of Microsoft Excel Extended ASCII Key Codes Excel (Office) Shortcut Keys Excel Training Workbook Excel Training - Warmup.xls Excel Training - Activity2-3.xls Excel Training - Activity8-16.xls Educational Links eeweb forums PSU Blackboard My PSU My OIT Tom Almy Forums Tom Almy's Site Raw MOV videos (ms.pdx.oit.edu) Videos (Mediaview) OIT Portland LTSpice Videos LTSpice WebCT Dr. Aboy Moodle OIT Moodle Other Links RF Cafe Agilent Educator Corner EDA Boards RCR IEEE Blog Archive May (1) May (1) November (1) September (1) October (1) May (1) April (1) February (1) January (1) December (1) November (2) October (2) September (3) July (1) March (1) November (1) October (3) September (1) August (1) May (4) April (5) February (8) January (9) November (2) October (1) August (1) June (1) April (1) January (2) December (1) October (3) March (2) February (2) January (1) ```
``` ```
``` ```
``` ```
``` ```
``` Free Counters Awesome Inc. theme. Powered by Blogger. ```
``` ```
``` ```
``` ```
``` window.setTimeout(function() { document.body.className = document.body.className.replace('loading', ''); }, 10); window['__wavt'] = 'AOuZoY7qQqX8sEVCDtmjdu7cYzeMp3LyuA:1558373852397';_WidgetManager._Init('//www.blogger.com/rearrange?blogID\x3d5732015422208460018','//jeastham.blogspot.com/2010/01/sum-of-sinusoids-triangle-approximation.html','5732015422208460018'); _WidgetManager._SetDataContext([{'name': 'blog', 'data': {'blogId': '5732015422208460018', 'title': 'James Eastham', 'url': 'http://jeastham.blogspot.com/2010/01/sum-of-sinusoids-triangle-approximation.html', 'canonicalUrl': 'http://jeastham.blogspot.com/2010/01/sum-of-sinusoids-triangle-approximation.html', 'homepageUrl': 'http://jeastham.blogspot.com/', 'searchUrl': 'http://jeastham.blogspot.com/search', 'canonicalHomepageUrl': 'http://jeastham.blogspot.com/', 'blogspotFaviconUrl': 'http://jeastham.blogspot.com/favicon.ico', 'bloggerUrl': 'https://www.blogger.com', 'hasCustomDomain': false, 'httpsEnabled': true, 'enabledCommentProfileImages': true, 'gPlusViewType': 'FILTERED_POSTMOD', 'adultContent': false, 'analyticsAccountNumber': '', 'encoding': 'UTF-8', 'locale': 'en', 'localeUnderscoreDelimited': 'en', 'languageDirection': 'ltr', 'isPrivate': false, 'isMobile': false, 'isMobileRequest': false, 'mobileClass': '', 'isPrivateBlog': false, 'feedLinks': '\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22James Eastham - Atom\x22 href\x3d\x22http://jeastham.blogspot.com/feeds/posts/default\x22 /\x3e\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/rss+xml\x22 title\x3d\x22James Eastham - RSS\x22 href\x3d\x22http://jeastham.blogspot.com/feeds/posts/default?alt\x3drss\x22 /\x3e\n\x3clink rel\x3d\x22service.post\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22James Eastham - Atom\x22 href\x3d\x22https://www.blogger.com/feeds/5732015422208460018/posts/default\x22 /\x3e\n\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22James Eastham - Atom\x22 href\x3d\x22http://jeastham.blogspot.com/feeds/7016909570191740227/comments/default\x22 /\x3e\n', 'meTag': '', 'adsenseHostId': 'ca-host-pub-1556223355139109', 'adsenseHasAds': false, 'ieCssRetrofitLinks': '\x3c!--[if IE]\x3e\x3cscript type\x3d\x22text/javascript\x22 src\x3d\x22https://www.blogger.com/static/v1/jsbin/1961721879-ieretrofit.js\x22\x3e\x3c/script\x3e\n\x3c![endif]--\x3e', 'view': '', 'dynamicViewsCommentsSrc': '//www.blogblog.com/dynamicviews/4224c15c4e7c9321/js/comments.js', 'dynamicViewsScriptSrc': '//www.blogblog.com/dynamicviews/3392fbbd1a294fe9', 'plusOneApiSrc': 'https://apis.google.com/js/plusone.js', 'disableGComments': true, 'sharing': {'platforms': [{'name': 'Get link', 'key': 'link', 'shareMessage': 'Get link', 'target': ''}, {'name': 'Facebook', 'key': 'facebook', 'shareMessage': 'Share to Facebook', 'target': 'facebook'}, {'name': 'BlogThis!', 'key': 'blogThis', 'shareMessage': 'BlogThis!', 'target': 'blog'}, {'name': 'Twitter', 'key': 'twitter', 'shareMessage': 'Share to Twitter', 'target': 'twitter'}, {'name': 'Pinterest', 'key': 'pinterest', 'shareMessage': 'Share to Pinterest', 'target': 'pinterest'}, {'name': 'Email', 'key': 'email', 'shareMessage': 'Email', 'target': 'email'}], 'disableGooglePlus': true, 'googlePlusShareButtonWidth': 300, 'googlePlusBootstrap': '\x3cscript type\x3d\x22text/javascript\x22\x3ewindow.___gcfg \x3d {\x27lang\x27: \x27en\x27};\x3c/script\x3e'}, 'hasCustomJumpLinkMessage': false, 'jumpLinkMessage': 'Read more', 'pageType': 'item', 'postId': '7016909570191740227', 'postImageThumbnailUrl': 'http://3.bp.blogspot.com/_sbY0T041H_0/S1SYRk-i7EI/AAAAAAAAA4k/LP3JrIne0hs/s72-c/dsp_triangle.bmp', 'postImageUrl': 'http://3.bp.blogspot.com/_sbY0T041H_0/S1SYRk-i7EI/AAAAAAAAA4k/LP3JrIne0hs/s400/dsp_triangle.bmp', 'pageName': 'Sum of Sinusoids Triangle Approximation', 'pageTitle': 'James Eastham: Sum of Sinusoids Triangle Approximation'}}, {'name': 'features', 'data': {'sharing_get_link_dialog': 'true', 'sharing_native': 'false'}}, {'name': 'messages', 'data': {'edit': 'Edit', 'linkCopiedToClipboard': 'Link copied to clipboard!', 'ok': 'Ok', 'postLink': 'Post Link'}}, {'name': 'template', 'data': {'name': 'Awesome Inc.', 'localizedName': 'Awesome Inc.', 'isResponsive': false, 'isAlternateRendering': false, 'isCustom': false, 'variant': 'dark', 'variantId': 'dark'}}, {'name': 'view', 'data': {'classic': {'name': 'classic', 'url': '?view\x3dclassic'}, 'flipcard': {'name': 'flipcard', 'url': '?view\x3dflipcard'}, 'magazine': {'name': 'magazine', 'url': '?view\x3dmagazine'}, 'mosaic': {'name': 'mosaic', 'url': '?view\x3dmosaic'}, 'sidebar': {'name': 'sidebar', 'url': '?view\x3dsidebar'}, 'snapshot': {'name': 'snapshot', 'url': '?view\x3dsnapshot'}, 'timeslide': {'name': 'timeslide', 'url': '?view\x3dtimeslide'}, 'isMobile': false, 'title': 'Sum of Sinusoids Triangle Approximation', 'description': ' Triangle Approximation: Sum of Sinusoids Example The following Matlab code provides an example of the fact that any signal can constructed...', 'featuredImage': 'http://3.bp.blogspot.com/_sbY0T041H_0/S1SYRk-i7EI/AAAAAAAAA4k/LP3JrIne0hs/s400/dsp_triangle.bmp', 'url': 'http://jeastham.blogspot.com/2010/01/sum-of-sinusoids-triangle-approximation.html', 'type': 'item', 'isSingleItem': true, 'isMultipleItems': false, 'isError': false, 'isPage': false, 'isPost': true, 'isHomepage': false, 'isArchive': false, 'isLabelSearch': false, 'postId': 7016909570191740227}}]); _WidgetManager._RegisterWidget('_NavbarView', new _WidgetInfo('Navbar1', 'navbar', document.getElementById('Navbar1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_HeaderView', new _WidgetInfo('Header1', 'header', document.getElementById('Header1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_BlogView', new _WidgetInfo('Blog1', 'main', document.getElementById('Blog1'), {'cmtInteractionsEnabled': false, 'lightboxEnabled': true, 'lightboxModuleUrl': 'https://www.blogger.com/static/v1/jsbin/839950701-lbx.js', 'lightboxCssUrl': 'https://www.blogger.com/static/v1/v-css/368954415-lightbox_bundle.css'}, 'displayModeFull')); _WidgetManager._RegisterWidget('_TextListView', new _WidgetInfo('TextList2', 'sidebar-right-1', document.getElementById('TextList2'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_ImageView', new _WidgetInfo('Image1', 'sidebar-right-1', document.getElementById('Image1'), {'resize': false}, 'displayModeFull')); _WidgetManager._RegisterWidget('_TextListView', new _WidgetInfo('TextList1', 'sidebar-right-1', document.getElementById('TextList1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList10', 'sidebar-right-1', document.getElementById('LinkList10'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList8', 'sidebar-right-1', document.getElementById('LinkList8'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList9', 'sidebar-right-1', document.getElementById('LinkList9'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList3', 'sidebar-right-1', document.getElementById('LinkList3'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList7', 'sidebar-right-1', document.getElementById('LinkList7'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList4', 'sidebar-right-1', document.getElementById('LinkList4'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList1', 'sidebar-right-1', document.getElementById('LinkList1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_LinkListView', new _WidgetInfo('LinkList5', 'sidebar-right-1', document.getElementById('LinkList5'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_BlogArchiveView', new _WidgetInfo('BlogArchive1', 'sidebar-right-1', document.getElementById('BlogArchive1'), {'languageDirection': 'ltr', 'loadingMessage': 'Loading\x26hellip;'}, 'displayModeFull')); _WidgetManager._RegisterWidget('_HTMLView', new _WidgetInfo('HTML1', 'footer-1', document.getElementById('HTML1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_HTMLView', new _WidgetInfo('HTML2', 'footer-2-1', document.getElementById('HTML2'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_AttributionView', new _WidgetInfo('Attribution1', 'footer-3', document.getElementById('Attribution1'), {}, 'displayModeFull')); ```