<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John Roach &#187; Frequency</title>
	<atom:link href="http://johnroach.info/tag/frequency/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnroach.info</link>
	<description>Coding for life</description>
	<lastBuildDate>Sun, 27 Jun 2010 08:05:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Amplitude Modulation of a cosine message</title>
		<link>http://johnroach.info/2010/02/amplitude-modulation-of-a-cosine-message/</link>
		<comments>http://johnroach.info/2010/02/amplitude-modulation-of-a-cosine-message/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 10:30:41 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[Coding for fun]]></category>
		<category><![CDATA[just fun]]></category>
		<category><![CDATA[Amplitude]]></category>
		<category><![CDATA[Carrier wave]]></category>
		<category><![CDATA[Frequency]]></category>
		<category><![CDATA[matlab]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=223</guid>
		<description><![CDATA[Hi there! Have some new code based on Matlab. It was actually a Computer Exercise for my Telecom course. It is an example of Amplitude Modulation of a Cos based message. The code is easy enough. If you have any questions please ask. Hope you enjoy it. 1 2 3 4 5 6 7 8 [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there! Have some new code based on <a class="zem_slink" href="http://www.mathworks.com/products/matlab/" title="MATLAB" rel="homepage">Matlab</a>. It was actually a Computer Exercise for my Telecom course. It is an example of Amplitude Modulation of a Cos based message. The code is easy enough. If you have any questions please ask. Hope you enjoy it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> am_modulation
&nbsp;
N=<span style="color: #33f;">2000</span>;
F=<span style="color: #080;">&#40;</span>-N/<span style="color: #33f;">2</span>:N/<span style="color: #33f;">2</span>-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>/N;
&nbsp;
user_entry1 = <span style="color: #0000FF;">input</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Please enter carrier freq [Press enter for default fc=0.25] :'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isempty<span style="color: #080;">&#40;</span>user_entry1<span style="color: #080;">&#41;</span>
    fc=<span style="color: #33f;">0.25</span>;
<span style="color: #0000FF;">else</span>
    fc=user_entry1;
<span style="color: #0000FF;">end</span>
&nbsp;
user_entry4 = <span style="color: #0000FF;">input</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Please enter amplitude of carrier wave [Press enter for default Ac=1] :'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isempty<span style="color: #080;">&#40;</span>user_entry4<span style="color: #080;">&#41;</span>
    Ac=<span style="color: #33f;">1</span>;
<span style="color: #0000FF;">else</span>
    Ac=user_entry4;
<span style="color: #0000FF;">end</span>
&nbsp;
n=<span style="color: #33f;">0</span>:<span style="color: #33f;">1</span>:<span style="color: #33f;">256</span>;
&nbsp;
c=Ac*<span style="color: #0000FF;">cos</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*n*fc<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">2</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>F, <span style="color: #0000FF;">fftshift</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">fft</span><span style="color: #080;">&#40;</span>c,N<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Carrier Wave at frequency-domain'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'frequency'</span><span style="color: #080;">&#41;</span>, <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'amplitude'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> on;
&nbsp;
&nbsp;
&nbsp;
user_entry2 = <span style="color: #0000FF;">input</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Please enter message freq [Press enter for default fm=0.01] :'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isempty<span style="color: #080;">&#40;</span>user_entry2<span style="color: #080;">&#41;</span>
    fm=<span style="color: #33f;">0.01</span>;
<span style="color: #0000FF;">else</span>
    fm=user_entry2;
<span style="color: #0000FF;">end</span>
&nbsp;
user_entry5 = <span style="color: #0000FF;">input</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Please enter message amplitude [Press enter for default Am=1] :'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isempty<span style="color: #080;">&#40;</span>user_entry5<span style="color: #080;">&#41;</span>
    Am=<span style="color: #33f;">1</span>;
<span style="color: #0000FF;">else</span>
    Am=user_entry5;
<span style="color: #0000FF;">end</span>
&nbsp;
m=Am*<span style="color: #0000FF;">cos</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*fm*n<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">2</span>,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>F, <span style="color: #0000FF;">fftshift</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">fft</span><span style="color: #080;">&#40;</span>m,N<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Message at frequency-domain'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'frequency'</span><span style="color: #080;">&#41;</span>, <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'amplitude'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> on;
&nbsp;
&nbsp;
user_entry3 = <span style="color: #0000FF;">input</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Please enter amplitude sensitivity cnst. [Press enter for default ka=0.5] :'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isempty<span style="color: #080;">&#40;</span>user_entry3<span style="color: #080;">&#41;</span>
    ka=<span style="color: #33f;">0.5</span>;
<span style="color: #0000FF;">else</span>
    ka=user_entry3;
<span style="color: #0000FF;">end</span>
&nbsp;
s=<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>+m.*ka<span style="color: #080;">&#41;</span>.*c;
&nbsp;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">2</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">3</span> <span style="color: #33f;">4</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>F,<span style="color: #0000FF;">fftshift</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">fft</span><span style="color: #080;">&#40;</span>s,N<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'AM waveform at frequency-domain'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'frequency'</span><span style="color: #080;">&#41;</span>, <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'amplitude'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> on;</pre></td></tr></table></div>

<p>Here is an example result of the code ;</p>
<p><center><img src="http://lh5.ggpht.com/_ays0jYAPwio/S4EJVluhDMI/AAAAAAAAAlM/ZGpIDgPyvKw/example_run.jpg?imgmax=512" alt="example_run.jpg" width="512" height="421" class="pie-img"><img style="margin:10px 10px 10px 10px;"/></img></center></p>
<p>Enjoy &#038; peace!</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=d209ba35-4b73-4a27-b7a1-50de76a2513c" style="border:none;float:right"><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2010/02/amplitude-modulation-of-a-cosine-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
