{"id":314,"date":"2010-02-16T20:49:30","date_gmt":"2010-02-16T20:49:30","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/2010\/02\/16\/sampling-a-cosine\/"},"modified":"2010-02-17T13:08:26","modified_gmt":"2010-02-17T13:08:26","slug":"sampling-a-cosine","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2010\/02\/16\/sampling-a-cosine\/","title":{"rendered":"Sampling a cosine"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>I know, I know ... I've really fallen behind in my blog posting the last month or so.  Shifting responsibilities in my \"real\r\n      job\" have left me snowed under for the last few weeks, and I haven't figured out yet how to adjust my schedule to keep up\r\n      with the blog.  Plus, the <a href=\"https:\/\/blogs.mathworks.com\/steve\/category\/fourier-transforms\/\">Fourier transform posts<\/a> take longer than usual for me to write.  Have no worries, though; I fully intend to return to posting about once a week.\r\n   <\/p>\r\n   <p>In the meantime, I have a homework problem for you.  Below I show samples taken from a cosine function:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2010\/aliasing_sampling_teaser.png\"> <\/p>\r\n   <p>[Update: t is in seconds.] Your task is to estimate the frequency of the cosine. <a href=\"https:\/\/blogs.mathworks.com\/steve\/2010\/02\/16\/sampling-a-cosine\/#respond\">Post your answer as a comment<\/a>, and be sure to give the units (Hz or rad\/s).\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_e6a948bce8c64152b0b3582d6cce6ba3() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='e6a948bce8c64152b0b3582d6cce6ba3 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' e6a948bce8c64152b0b3582d6cce6ba3';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = '';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_e6a948bce8c64152b0b3582d6cce6ba3()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.9<br><\/p>\r\n<\/div>\r\n<!--\r\ne6a948bce8c64152b0b3582d6cce6ba3 ##### SOURCE BEGIN #####\r\n%%\r\n% I know, I know ... I've really fallen behind in my blog posting the last\r\n% month or so.  Shifting responsibilities in my \"real job\" have left me snowed\r\n% under for the last few weeks, and I haven't figured out yet how to adjust my\r\n% schedule to keep up with the blog.  Plus, the \r\n% <https:\/\/blogs.mathworks.com\/steve\/category\/fourier-transforms\/ Fourier transform posts>\r\n% take\r\n% longer than usual for me to write.  Have no worries, though; I fully intend to\r\n% return to posting about once a week.\r\n%\r\n% In the meantime, I have a homework problem for you.  Below I show samples\r\n% taken from a cosine function:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2010\/aliasing_sampling_teaser.png>>\r\n%\r\n% Your task is to estimate the frequence of the cosine.  \r\n% <https:\/\/blogs.mathworks.com\/steve\/2010\/02\/16\/sampling-a-cosine\/#respond \r\n% Post your answer as a comment>, and be sure to give the units (Hz or rad\/s).\r\n##### SOURCE END ##### e6a948bce8c64152b0b3582d6cce6ba3\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   I know, I know ... I've really fallen behind in my blog posting the last month or so.  Shifting responsibilities in my \"real\r\n      job\" have left me snowed under for the last few weeks, and I... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2010\/02\/16\/sampling-a-cosine\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/314"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=314"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/314\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}