I am now ITIL Foundation Certified!

Qasim_AbdulRasoo_ITIL_Foundations

One more step to becoming an ITIL Practitioner!

For those who have no idea about ITIL

http://en.wikipedia.org/wiki/Information_Technology_Infrastructure_Library

The Information Technology Infrastructure Library (ITIL) is a set of practices for IT service management (ITSM) that focuses on aligning IT services with the needs of business. In its current form (known as ITIL 2011 edition), ITIL is published in a series of five core publications, each of which covers an ITSM lifecycle stage. ITIL underpins ISO/IEC 20000 (previously BS15000), the International Service Management Standard for IT service management, although differences between the two frameworks do exist.

ITIL_2011_Qualification_Scheme

Yup, much remains!

Have a great day,

Membership of the Joint External Advisory Board of the College of IT and Engineering at Ahlia University


Ahlia_University-logo

Members

 

I was chosen by Ahlia University’s Management to be a member of the  Joint External Advisory Board of the College of IT and Engineering, being one of three Alumni members of the committee.

As a graduate of that college with a Bachelors in Mobile & Network Engineering, and as the 3rd President of the Students Council and once an employee of the University’s Administration, along with receiving Technical positions in the job market, then commercial roles and now I  becoming a Director of Q&A Advisory that I am opening along with my father, Ahlia University asked me to join the Joint External Advisory Board for the sake of improving the currently praised performance of the College, where the University’s is aiming at bringing out innovative talents in the field of IT for the internal and external jobs market, along with emphasizing on the importance on the importance of innovative entrepreneurship in the field of IT.

What I am intending to do is to emphasis on the importance of what is greatly neglected in the local market of the Open Source systems and software. With the power granted by the University’s management, a grant for Best Linux Project is what I am intending to give to the student with the most interesting project with Linux Operating System, whether it is in the form of an Embedded System, a Raspberry Pi, a Workstation or even a Server would be eligible to receive a grant that would half his tuition fees for one year.

As things progress I am intending to provide more with whatever permissions I am get from the University, even reaching a stage where a Linux lab is established for the enthusiasts & those who want to be certified, or even become entrepreneurs in the field.

I hope this project would flower talents that would contribute to the technological status in Bahrain, where talents and entrepreneurs with amazing ideas and projects would change the current scene of Information Technology at this part of the world, and may God bless.

Cure Diseases with Folding@home!

Ever imagined how you can participate in curing diseases like cancer, Alzheimer and other diseases since was not able to discover a cure for yet?

Do you have to have a PhD and research such medicines in a lab wearing a white lab coat, working day & night leaving hanging out with your friends aside and concentrate on transparent tubes with liquid inside, looking into microscopes and making sure your Bio-suit prevents air from outside getting in or otherwise what’s left of your life would be measured in minutes after being infected by a dangerous virus?

You can do that while you are sleeping 🙂

Let your machines do that for you!

With folding@home you’ll be able to do that, where your PC, workstation and even your PS3 will be calculating protein folds in order to discover ways to cure diseases. This project is administrated by Standford University, the same University Google makers graduated from. All you have to do is download the client program for your PC (or run the already-installed program in your PS3) and let it work as a screensaver whenever your machine is idle.

Join Team 110997 Bahrain Team and follow the news of the team at BahrainFolds.org. Help humanity cure diseases!

Raspberry Pi Digital Clock

20121201_193429

I recommend using a Linux operating system equipped computer (i.e. Ubuntu) with this tutorial for further learning experience, but Windows would be just fine as well.

As my Fiancée had her clock broken, I decided to start this project where I made a digital clock using a Raspberry Pi connected to a  3.5 Inch TFT LCD Monitor for Car / Automobile. The Raspberry Pi had a SD Card containing Debian Raspbian “wheezy” operating system (instructions of installing such OS on a SD card will come later in this tutorial) .

The idea here is to start an HTML page with JavaScript at full screen upon the running of Raspbian “wheezy” (that have been dumped on an SD card using dd on a Raspberry Pi connected to an external monitor. Such tutorial can be used for a monitor that can be connected to using either a composite video output yellow jack or an HDMI cable. In addition to the HTML with JavaScript file that will display day, date & time on the monitor, modification was done to a file & programs were installed to have this clock running smoothly the way we look forward to see in a digital clock.

Such file that is to be modified here is the /etc/xdg/lxsession/LXDE/autostart file that can be modified using your favourite text editor (like nano or GEdit) to add a full screen kiosk-like browser launch of Digital Clock at start-up by Debian Wheezy’s default lightweight browser (Midori), and the installation of Unclutter that will hide your mouse from the screen after a certain period of time that can be changed (it comes with a default one-second-then-hide for your cursor).

 OK, long story short, this is what you will need to get started:

HARDWARE

  • Raspberry Pi Model A or B it really does not matter, especially with our low hardware specification requirements project, maybe the only difference would be the time for the Raspbian Wheezy image to load & start your Digital Clock in Midori.
  • A Micro USB charger of 5V and 0.7 ~ 1.2A (I used my Samsung Galaxy S II charger that outputs 5V 1A) for the Raspberry Pi.
  • A 2 GB SD card (as you would not need more space, anything that can handle Raspbian Wheezy would be enough. I will use a SD card I already have).
  • A monitor with either composite or HDMI input (I got this 3.5 Inch TFT LCD Monitor for Car / Automobile from Amazon for $17.99++).
  • A 12V 0.5A power adapter for the LCD TFT Monitor (previous monitor does not come with a wall socket power adapter because it is made to be placed inside a car and have car power supplied to such monitor. I used a Western Digital Hard Disk power adapter that supplies 12V 0.25A and worked just fine with the monitor).
  • A composite cable (to be connected to the TFT LCR Monitor).

SOFTWARE

OK, let’s get started!

  • Download the Debian Raspbian “wheezy” image from RaspberryPi.org/Downloads and extract the .img file inside the downloaded ZIP file.
  • Have the image written on your SD Card using WinDD (if you are on a Windows) or dd (if you are on a Linux). Of course I am assuming that you already have an SD Card reader attached or placed to your computer, otherwise you will not be able to continue with this tutorial 🙂 (worst case you can buy one from any computer store around!). I will show you how you would do that using dd. Be noted that the process of writing an IMG file to any storage would mean the loss of all information on that destination permanently. USE IT WITH UTMOST CAUTION, make sure of your written commands! Make a backup of your SD Card if it contains information you do not want to lose. You’ll also need root privileges during that process. 
  • Make sure you know what the SD Card have been recognized by Linux insertion using the fdisk -l command with root privileges

sudo fdisk -l

  • fdisk is a Linux disk format utility, but with the  -l option it lists all the attached storage devices & partitions. After entering the sudo password (the password of your current account, assuming your current account have administrative privileges), hit enter & look for a line with storage space identical to the SD Card you inserted. You should get a list similar to this one (I used a 4GB SD card in this example).

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3f938c99

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      819199      408576   27  Hidden NTFS WinRE
/dev/sda2          819200   488070887   243625844    7  HPFS/NTFS/exFAT
/dev/sda3       488073216   550789119    31357952    7  HPFS/NTFS/exFAT
/dev/sda4       550791166   976771071   212989953    f  W95 Ext’d (LBA)
/dev/sda5       550791168   874371071   161789952    7  HPFS/NTFS/exFAT
/dev/sda6       874373120   959193432    42410156+  83  Linux
/dev/sda7       959195136   976771071     8787968   82  Linux swap / Solaris

Disk /dev/sdb: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders, total 7744512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dbfc6

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdb2          122880     7744511     3810816   83  Linux

It obvious that /dev/sdb is the one that has 4GB of storage space, therefore it is our target media device.

  • Write the image we just downloaded & extracted to the SD Card we inserted. We’ll need administrative privileges here too.

sudo dd if=/home/username/download_location/2012-10-28-wheezy-raspbian.img of=/dev/sdb

Alright, let’s breakdown the last command line: sudo was explained moments ago (dd cannot be issued without administrative privileges), dd stands for Disk Dump, a command to store a certain image file / disk as an image in a file /  disk EXACTLY the same as the destination file / disk. if is the input file, followed by the destination of the input file (Debian Wheezy image in this case. Note that at the time of writing this tutorial, the “2012-10-28-wheezy-raspbian.img” was the latest release). of is the output file, in which in this case a device, the 4GB SD card that all info on it will be wiped out & have the Debian Wheezy image written on such card instead, located on /dev/sdb.

This process will take time, so be patient 🙂 you might think your PC got stuck or something went wrong, but worry not! All is going well, this normally takes time 😉 go grab a cup of tea, coffee, hot hibiscus and by the time you’re done drinking your hot drink it will be done 😀

  • You should get something like that

3788800+0 records in
3788800+0 records out
1939865600 bytes (1.9 GB) copied, 698.19 s, 2.8 MB/s

OK, congratulations! you have installed Debian Wheezy on your SD Card! Now you are ready to fire up your SD Card in your Raspberry Pi device, but we shall place the Digital Clock program within our Raspberry Pi first.

  • Run your favourite text editor / HTML IDE with administrative privileges. I used Bluefish

sudo bluefish

Bluefish editor will appear. The script here for Digital Clock was created by JavaScriptKit.com. The link to the Clock tutorial is located here.

//LCD Clock script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

  • We start illustrating the file by writing an ordinary HTML file structure to the blank document we made in Bluefish.

<html>

<head>

 

</head>

 

<body>

 

 

 

 

</body>

</html>

  • Insert the following style sheet to the <HEAD> section of your page, between the <head> and the </head>

<style>
<!–
.styling{
background-color:black;
color:lime;
font: bold 16px MS Sans Serif;
padding: 3px;
}
–>
</style>

  • Add the below code into the <BODY>, where you wish the clock to appear between the <body> and the </body>

<span id=”digitalclock”></span>

<script>
<!–

//LCD Clock script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

var alternate=0
var standardbrowser=!document.all&&!document.getElementById

if (standardbrowser)
document.write(‘<form name=”tick”><input type=”text” name=”tock” size=”11″></form>’)

function show(){
if (!standardbrowser)
var clockobj=document.getElementById? document.getElementById(“digitalclock”) : document.all.digitalclock
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var dn=”AM”

if (hours==12) dn=”PM”
if (hours>12){
dn=”PM”
hours=hours-12
}
if (hours==0) hours=12
if (hours.toString().length==1)
hours=”0″+hours
if (minutes<=9)
minutes=”0″+minutes

if (standardbrowser){
if (alternate==0)
document.tick.tock.value=hours+” : “+minutes+” “+dn
else
document.tick.tock.value=hours+”   “+minutes+” “+dn
}
else{
if (alternate==0)
clockobj.innerHTML=hours+” : “+minutes+” “+”<sup style=’font-size:1px’>”+dn+”</sup>”
else
clockobj.innerHTML=hours+” : “+minutes+” “+”<sup style=’font-size:1px’>”+dn+”</sup>”
}
alternate=(alternate==0)? 1 : 0
setTimeout(“show()”,1000)
}
window.onload=show

//–>
</script>

<p>This free script provided by<br />
<a href=”http://javascriptkit.com”>JavaScript
Kit</a></p>

OK! Pretty much that’s for the Digital Clock!

You should have the following script on your Bluefish editor

<html>

<head>

<style>
<!–
.styling{
background-color:black;
color:lime;
font: bold 16px MS Sans Serif;
padding: 3px;
}
–>
</style>

</head>

<body>

<span id=”digitalclock”></span>

<script>
<!–

//LCD Clock script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

var alternate=0
var standardbrowser=!document.all&&!document.getElementById

if (standardbrowser)
document.write(‘<form name=”tick”><input type=”text” name=”tock” size=”11″></form>’)

function show(){
if (!standardbrowser)
var clockobj=document.getElementById? document.getElementById(“digitalclock”) : document.all.digitalclock
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var dn=”AM”

if (hours==12) dn=”PM”
if (hours>12){
dn=”PM”
hours=hours-12
}
if (hours==0) hours=12
if (hours.toString().length==1)
hours=”0″+hours
if (minutes<=9)
minutes=”0″+minutes

if (standardbrowser){
if (alternate==0)
document.tick.tock.value=hours+” : “+minutes+” “+dn
else
document.tick.tock.value=hours+”   “+minutes+” “+dn
}
else{
if (alternate==0)
clockobj.innerHTML=hours+” : “+minutes+” “+”<sup style=’font-size:1px’>”+dn+”</sup>”
else
clockobj.innerHTML=hours+” : “+minutes+” “+”<sup style=’font-size:1px’>”+dn+”</sup>”
}
alternate=(alternate==0)? 1 : 0
setTimeout(“show()”,1000)
}
window.onload=show

//–>
</script>

<p>This free script provided by<br />
<a href=”http://javascriptkit.com”>JavaScript
Kit</a></p>

</body>

</html>

Have it saved on your SD Card. I prefer having it saved in /home/pi/ and save it as digitalclock.html. Full filename would be /home/pi/digitalclock.html. But if you are using a Windows PC then you will not be able to save it directly into your SD Card. I would strongly recommend opening this page with your Raspberry Pi and save it then in /home/pi as digitalclock.html using any editor you like such as “gedit”.

Open your DigitalClock.html with your web browser on your computer. You should get something like this

Screenshot from 2012-11-29 16:58:48

Personally I was not satisfied with the very, very moderate time output. I wanted to display seconds in real time, add some style to that clock, day, day of the month, month, year… etc. So I did this

Screenshot from 2012-11-29 17:07:06-1

How I did it? I illustrated the following script

<head>
<style>
<!–
.styling{
background-color:black;
color:white;
font: bold 50px Lucida Console;
padding: 3px;
}
–>
</style>
</head>

<body bgcolor = black>

<table width=100% height=100%>
<tr>
<td style=”text-align: center; vertical-align: middle;”>

<span id=”digitalclock”></span>

<script>

//LCD Clock script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

var alternate=0
var standardbrowser=!document.all&&!document.getElementById

if (standardbrowser)
document.write(‘<form name=”tick”><input type=”text” name=”tock” size=”11″></form>’)

function show(){
if (!standardbrowser)
var clockobj=document.getElementById? document.getElementById(“digitalclock”) : document.all.digitalclock
var Digital=new Date()
var date=Digital.getDate()
var year=Digital.getFullYear()

var monthn = new Array(12)
monthn[0]=”JAN”;
monthn[1]=”FEB”;
monthn[2]=”MAR”;
monthn[3]=”APR”;
monthn[4]=”MAY”;
monthn[5]=”JUN”;
monthn[6]=”JUL”;
monthn[7]=”AUG”;
monthn[8]=”SEP”;
monthn[9]=”OCT”;
monthn[10]=”NOV”;
monthn[11]=”DEC”;
var month=monthn[Digital.getMonth()]

var weekday=new Array(7);
weekday[0]=”SUN”;
weekday[1]=”MON”;
weekday[2]=”TUE”;
weekday[3]=”WED”;
weekday[4]=”THU”;
weekday[5]=”FRI”;
weekday[6]=”SAT”;
var day=weekday[Digital.getDay()]

var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn=”AM”

if (hours==12) dn=”PM”
if (hours>12){
dn=”PM”
hours=hours-12
}
if (hours==0) hours=12
//if (hours.toString().length==1)
//hours=”0″+hours
if (minutes<=9)
minutes=”0″+minutes

if (seconds<=9)
seconds=”0″+seconds

if (standardbrowser){
if (alternate==0)
document.tick.tock.value=hours+” : “+minutes+” “+dn
else
document.tick.tock.value=hours+”   “+minutes+” “+dn
}
else{
if (alternate==0)
clockobj.innerHTML=”<b style=’font-size:120′>” + day + “</b> ” +”<b style=’font-size:50′>” + month + “</b>” + ” <b style=’font-size:120px’>” + date + “</b>” + “&emsp;” + “<b style=’font-size:60px’>” + year +”</b> <br>”

+”<b style=’font-size:300px’>”+hours+”</b>”+” <sup style=’font-size:40px’>”+dn+”</sup> <b style=’font-size:200px’>”+minutes+”</b><sup> : </sup>”+”<b style=’font-size:125px’>” + seconds+”</b>”
else

clockobj.innerHTML=”<b style=’font-size:120′>” + day + “</b> ” + “<b style=’font-size:50′>” + month + “</b>” + ” <b style=’font-size:120px’>” + date + “</b>” + “&emsp;” + “<b style=’font-size:60px’>” + year +”</b> <br>”

+”<b style=’font-size:300px’>”+hours+”</b>”+” <sup style=’font-size:40px’>”+dn+”</sup> <b style=’font-size:200px’>”+minutes+”</b><sup> : </sup>”+”<b style=’font-size:125px’>” + seconds+”</b>”
}
alternate=(alternate==0)? 1 : 0
setTimeout(“show()”,1000)
}
window.onload=show

</script>

</td>
</tr>
</table>

</body>

</html>

Copy it and paste it in place of the previous script. Tada! You got a cooler Digital Clock now 😉

Well, an HTML page with JavaScript did the trick. What remains is some modification and we shall be done with our Raspberry Pi Digital Clock.

We need to

  1. start-up the Raspberry Pi with this HTML file.
  2. Hide the mouse once the clock appears.
  3. Disable the screen saver from working.

Step by step,

  1. Modify the /etc/xdg/lxsession/LXDE/autostartlocated in your Raspberry Pi SD Card (do not mistaken it with the one you have on your computer! make sure that you don’t edit the one in your Linux operating system, but the one located WITHIN your SD Card) with your favourite text editor. I would go again with Bluefish. Add a line to the end of the file with the following script

    @midori -e Fullscreen -a /home/pi/digitalclock.html

  2. Install Unclutter

    sudo apt-get install unclutter

  3. Disable the Screen Saver by installing xset

    sudo apt-get install x11-xserver-utils

    Now open up your ~/.xinitrc file (if you don’t have one then create it) and enter this:

    xset s off # don’t activate screensaver
    xset -dpms # disable DPMS (Energy Star) features.
    xset s noblank # don’t blank the video device

    exec /etc/alternatives/x-session-manager # start lxde

We are done here! I hope you enjoyed this tutorial, and if you have any question in mind regarding any step, a suggestion in mind to make this application better or a completely different idea don’t hesitate to post it as a comment here, or even better open a topic at the forums in The Assembly.

have a great day! 😀

Install LAMP on Ubuntu in one command

LAMP stands for Linux, Apache, MySQL and PHP. According to Wikipedia

LAMP is a solution stack of free, open source software. The acronymLAMP refers to the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software, but now sometimes MariaDB) and originally PHP (but now sometimes Perl or Python), principal components to build a viable general purpose web server.[1]

If you want to have a web server running on your Linux box with Ubuntu installed, all you have to do is type the following command line in the terminal

sudo apt-get install lamp-server^

“sudo” is used here to get root privileges, as the installation process of LAMP solution stack requires root privileges (if you are executing this command while logging in as “root” then there is no need to add it to the command). “apt-get install” grabs & installs the software bundle of LAMP Server by the Advanced Packaging Tool (APT).

Don’t forget to add the “^” at the end of the command! As missing it out will result in the failure of the operation 😉

Complete the process, and you’ll have a web server running in a very short span of time!

Still having issues installing it? Check out the following video

Test your server by visiting to the following address your web browser

http://localhost

If you saw the following page

apache-install-success

Then it works just well!!!

Great, one bonus command as you have completed the previous one!

Want to get PHPMyAdmin to create, configure, maintain and delete your MySQL databases? install phpmyadmin!

sudo apt-get install phpmyadmin

Moments and you’ll have your PHPMyAdmin up and running along with your server 🙂

Qasim Al-Khuzaie | eHulool | The Social Blog

This article of mine was published on eHulool. PDF file of the article is linked to here. Enjoy reading 🙂

Comparativo-de-Google-Drive-vs-Dropbox-vs-Microsoft-SkyDrive-vs-Apple-iCloud-vs-Amazon-Cloud-Drive

Qasim Al-Khuzaie | eHulool | The Social Blog.

[UPDATE: IMPORTANT:: READ FIRST COMMENT OF MINE!]

Pulse Amplitude Modulation & Demodulation – Application in MATLAB

pamdemod

Pulse amplitude demodulation [1]

Syntax

z = pamdemod(y,M)
z = pamdemod(y,M,ini_phase)
z = pamdemod(y,M,ini_phase,symbol_order)

Description

z = pamdemod(y,M) demodulates the complex envelope y of a pulse amplitude modulated signal. M is the alphabet size. The ideal modulated signal should have a minimum Euclidean distance of 2.

z = pamdemod(y,M,ini_phase) specifies the initial phase of the modulated signal in radians.

z = pamdemod(y,M,ini_phase,symbol_order) specifies how the function assigns binary words to corresponding integers. If symbol_order is set to 'bin' (default), the function uses a natural binary-coded ordering. If symbol_order is set to 'gray', it uses a Gray-coded ordering.

Examples

The example in Comparing Theoretical and Empirical Error Rates uses this function.

pammod

Pulse amplitude modulation [2]

Syntax

y = pammod(x,M)
y = pammod(x,M,ini_phase)
y = pammod(x,M,ini_phase,symbol_order)

Description

y = pammod(x,M) outputs the complex envelope y of the modulation of the message signal x using pulse amplitude modulation. M is the alphabet size. The message signal must consist of integers between 0 and M-1. The modulated signal has a minimum Euclidean distance of 2. If x is a matrix with multiple rows, the function processes the columns independently.

y = pammod(x,M,ini_phase) specifies the initial phase of the modulated signal in radians.

y = pammod(x,M,ini_phase,symbol_order) specifies how the function assigns binary words to corresponding integers. If symbol_order is set to 'bin' (default), the function uses a natural binary-coded ordering. If symbol_order is set to 'gray', it uses a Gray constellation ordering.

Examples

The example in Comparing Theoretical and Empirical Error Rates uses this function.

plot (channel)

Plot channel characteristics with channel visualization tool [3]

Syntax

plot(h)

Description

plot(h), where h is a channel object, launches the channel visualization tool. This GUI tool allows you to plot channel characteristics in various ways. See Using the Channel Visualization Tool for details.

Examples

Examples using this plotting tool are found in Examples of Using the Channel Visualization Tool.

From Wave File

Read audio data from Microsoft Wave (.wav) file

Library

Signal Processing Sources

dspsrcs4

Description

The From Wave File block reads audio data from a Microsoft Wave (.wav) file and generates a signal with one of the data types and amplitude ranges in the following table.

Output Data Type Output Amplitude Range
double ±1
single ±1
int16 -32768 to 32767 (-215 to 215 – 1)
uint8 0 to 255

The audio data must be in uncompressed pulse code modulation (PCM) format.

y = wavread('filename')       % Equivalent MATLAB code

The block supports 8-, 16-, 24-, and 32-bit Microsoft Wave (.wav) files.

The File name parameter can specify an absolute or relative path to the file. When the file is on the MATLAB path or in the current directory (the directory returned by typing pwd at the MATLAB command line), you need only specify the file’s name. You do not need to specify the.wav extension.

For an audio file containing C channels, the block’s output is an M-by-C matrix containing one frame (M consecutive samples) of audio data from each channel. The frame size, M, is specified by the Samples per output frame parameter. For M=1, the output is sample based; otherwise, the output is frame based.

The output frame period, Tfo, is

where Fs is the data sample rate in Hz.

To reduce the required number of file accesses, the block acquires L consecutive samples from the file during each access, where L is specified by the Minimum number of samples for each read from file parameter ( ). For , the block instead acquires M consecutive samples during each access. Larger values of L result in fewer file accesses, which reduces run-time overhead.

Use the Data type parameter to specify the data type of the block’s output. Your choices are double, single, uint8, or int16.

Select the Loop check box if you want to play the file more than once. Then, enter the number of times to play the file. The number you enter must be a positive integer or inf.

Use the Number of times to play file parameter to enter the number of times to play the file. The number you enter must be a positive integer or inf, to play the file until you stop the simulation.

The Samples restart parameter determines whether the samples from the audio file repeat immediately or repeat at the beginning of the next frame output from the output port. When you select immediately after last sample, the samples repeat immediately. When you select at beginning of next frame, the frame containing the last sample value from the audio file is zero padded until the frame is filled. The block then places the first sample of the audio file in the first position of the next output frame.

Use the Output start-of-file indicator parameter to determine when the first audio sample in the file is output from the block. When you select this check box, a Boolean output port labeled SOF appears on the block. The output from the SOF port is 1 when the first audio sample in the file is output from the block. Otherwise, the output from the SOF port is 0.

Use the Output end-of-file indicator parameter to determine when the last audio sample in the file is output from the block. When you select this check box, a Boolean output port labeled EOF appears on the block. The output from the EOF port is 1 when the last audio sample in the file is output from the block. Otherwise, the output from the EOF port is 0.

The block icon shows the name, sample rate (in Hz), number of channels (1 or 2), and sample width (in bits) of the data in the specified audio file. All sample rates are supported; the sample width must be either 8, 16, 24, or 32 bits.

Dialog Box

File name
Enter the path and name of the file to read. Paths can be relative or absolute.

Samples per output frame
Enter the number of samples in each output frame, M.

Minimum number of samples for each read from file
Enter the number of consecutive samples to acquire from the file with each file access, L.

Data type
Select the output data type: double, single, uint8, or int16. The data type setting determines the output’s amplitude range, as shown in the preceding table.

Loop
Select this check box if you want to play the file more than once.

Number of times to play file
Enter the number of times you want to play the file.

Samples restart
Select immediately after last sample to repeat the audio file immediately. Select at beginning of next frame to place the first sample of the audio file in the first position of the next output frame.

Output start-of-file indicator
Use this check box to determine whether the output contains the first audio sample in the file.

Output end-of-file indicator
Use this check box to determine whether the output contains the last audio sample in the file.

Supported Data Types

  • Double-precision floating point
  • Single-precision floating point
  • 16-bit signed integer
  • 8-bit unsigned integer

To learn how to convert your data types to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

From Wave Device Signal Processing Blockset
Signal From Workspace Signal Processing Blockset
To Wave File Signal Processing Blockset
wavread MATLAB

G711 Codec

Quantize narrowband speech input signals

Library

Quantizers

dspquant2

Description

The G711 Codec block is a logarithmic scalar quantizer designed for narrowband speech. Narrowband speech is defined as a voice signal with an analog bandwidth of 4 kHz and a Nyquist sampling frequency of 8 kHz. The block quantizes a narrowband speech input signal so that it can be transmitted using only 8-bits. The G711 Codec block has three modes of operation: encoding, decoding, and conversion. You can choose the block’s mode of operation by setting the Mode parameter.

If, for the Mode parameter, you choose Encode PCM to A-law, the block assumes that the linear PCM input signal has a dynamic range of 13 bits. Because the block always operates in saturation mode, it assigns any input value above to and any input value below to . The block implements an A-law quantizer on the input signal and outputs A-law index values. When you choose Encode PCM to mu-law, the block assumes that the linear PCM input signal has a dynamic range of 14 bits. Because the block always operates in saturation mode, it assigns any input value above to and any input value below to . The block implements a mu-law quantizer on the input signal and outputs mu-law index values.

If, for the Mode parameter, you choose Decode A-law to PCM, the block decodes the input A-law index values into quantized output values using an A-law lookup table. When you choose Decode mu-law to PCM, the block decodes the input mu-law index values into quantized output values using a mu-law lookup table.

If, for the Mode parameter, you choose Convert A-law to mu-law, the block converts the input A-law index values to mu-law index values. When you choose Convert mu-law to A-law, the block converts the input mu-law index values to A-law index values.

Note Set the Mode parameter to Convert A-law to mu-law or Convert mu-law to A-law only when the input to the block is A-law or mu-law index values.

If, for the Mode parameter, you choose Encode PCM to A-law or Encode PCM to mu-law, the Overflow diagnostic parameter appears on the block parameters dialog box. Use this parameter to determine the behavior of the block when overflow occurs. The following options are available:

  • Ignore — Proceed with the computation and do not issue a warning message.
  • Warning -— Display a warning message in the MATLAB Command Window, and continue the simulation.
  • Error — Display an error dialog box and terminate the simulation.
Note Like all diagnostic parameters on the Configuration Parameters dialog box, Overflow diagnostic parameter is set to Ignore in the Real-Time Workshop code generated for this block.

Dialog Box

Mode
  • When you choose Encode PCM to A-law, the block implements an A-law encoder.
  • When you choose Encode PCM to mu-law, the block implements a mu-law encoder.
  • When you choose Decode A-law to PCM, the block decodes the input index values into quantized output values using an A-law lookup table.
  • When you choose Decode mu-law to PCM, the block decodes the input index values into quantized output values using a mu-law lookup table.
  • When you choose Convert A-law to mu-law, the block converts the input A-law index values to mu-law index values.
  • When you choose Convert mu-law to A-law, the block converts the input mu-law index values to A-law index values.
Overflow diagnostic
Use this parameter to determine the behavior of the block when overflow occurs.

  • Select Ignore to proceed with the computation without a warning message.
  • Select Warning to display a warning message in the MATLAB Command Window and continue the simulation.
  • Select Error to display an error dialog box and terminate the simulation.

This parameter is only visible if, for the Mode parameter, you select Encode PCM to A-law or Encode PCM to mu-law.

References

ITU-T Recommendation G.711, “Pulse Code Modulation (PCM) of Voice Frequencies,” General Aspects of Digital Transmission Systems; Terminal Equipments, International Telecommunication Union (ITU), 1993.

Supported Data Types

Port Supported Data Types
PCM
  • 16-bit signed integers
A
  • 8-bit unsigned integers
mu
  • 8-bit unsigned integers

To learn how to convert your data types to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

Quantizer Simulink
Scalar Quantizer Decoder Signal Processing Blockset
Scalar Quantizer Design Signal Processing Blockset
Uniform Decoder Signal Processing Blockset
Uniform Encoder Signal Processing Blockset
Vector Quantizer Decoder Signal Processing Blockset
Vector Quantizer Design Signal Processing Blockset
Vector Quantizer Encoder Signal Processing Blockset

[1] Pulse Amplitude Demodulation

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/pamdemod.html

[2] Pulse Amplitude Modulation

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/pammod.html

[3] Plot (channel)

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/plotchannel.html

Modulation in MATLAB

This part is regarding acquiring information for the modulation process of a WAV file saved on the computer’s memory to be modulated using MATLAB, taken directly from online help documentations:

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/fp59183.html

Modulation [1] in MATLAB


In most media for communication, only a fixed range of frequencies is available for transmission. One way to communicate a message signal whose frequency spectrum does not fall within that fixed frequency range, or one that is otherwise unsuitable for the channel, is to alter a transmittable signal according to the information in your message signal. This alteration is called modulation, and it is the modulated signal that you transmit. The receiver then recovers the original signal through a process called demodulation.

The sections of this chapter are as follows.

Modulation Features of the Toolbox

Modulation Terminology

Analog Modulation

Digital Modulation

Using Modem Objects

Selected Bibliography for Modulation

Modulation Features of the Toolbox [2]

The available methods of modulation depend on whether the input signal is analog or digital. The tables below show the modulation techniques that the Communications Toolbox supports for analog and digital signals, respectively.

Analog Modulation Method Acronym Function or Method
Amplitude modulation (suppressed or transmitted carrier) AM ammod, amdemod
Frequency modulation FM fmmod, fmdemod
Phase modulation PM pmmod, pmdemod
Single sideband amplitude modulation SSB ssbmod, ssbdemod

Digital Modulation Method Acronym Function or Method
Differential phase shift keying modulation DPSK dpskmod, dpskdemod
Frequency shift keying modulation FSK fskmod, fskdemod
Minimum shift keying modulation MSK mskmod, mskdemod
Offset quadrature phase shift keying modulation OQPSK oqpskmod, oqpskdemod
Phase shift keying modulation PSK modulate method on modem.pskmod object, demodulate method on modem.pskdemod object
Pulse amplitude modulation PAM pammod
Quadrature amplitude modulation QAM modulate method on modem.qammod object, demodulate method on modem.qamdemod object

Baseband vs. Passband Simulation

For a given modulation technique, two ways to simulate modulation techniques are called baseband and passband. Baseband simulation, also known as the lowpass equivalent method, requires less computation. This toolbox supports baseband simulation for digital modulation and passband simulation for analog modulation.

Modulation Terminology

Modulation is a process by which a carrier signal is altered according to information in a message signal. The carrier frequency, denoted Fc, is the frequency of the carrier signal. The sampling rate is the rate at which the message signal is sampled during the simulation.

The frequency of the carrier signal is usually much greater than the highest frequency of the input message signal. The Nyquist sampling theorem requires that the simulation sampling rate Fs be greater than two times the sum of the carrier frequency and the highest frequency of the modulated signal in order for the demodulator to recover the message correctly.

Analog Modulation [3]

This section describes how to represent analog signals using vectors or matrices. It provides examples of using the analog modulation and demodulation functions.

Representing Analog Signals

To modulate an analog signal using this toolbox, start with a real message signal and a sampling rate Fs in hertz. Represent the signal using a vector x, the entries of which give the signal’s values in time increments of 1/Fs. Alternatively, you can use a matrix to represent a multichannel signal, where each column of the matrix represents one channel.

For example, if t measures time in seconds, then the vector x below is the result of sampling a sine wave 8000 times per second for 0.1 seconds. The vector y represents the modulated signal.

Fs = 8000; % Sampling rate is 8000 samples per second. Fc = 300; % Carrier frequency in Hz t = [0:.1*Fs]'/Fs; % Sampling times for .1 second x = sin(20*pi*t); % Representation of the signal y = ammod(x,Fc,Fs); % Modulate x to produce y. figure; subplot(2,1,1); plot(t,x); % Plot x on top. subplot(2,1,2); plot(t,y)% Plot y below.

As a multichannel example, the code below defines a two-channel signal in which one channel is a sinusoid with zero initial phase and the second channel is a sinusoid with an initial phase of pi/8.

Fs = 8000; t = [0:.1*Fs]'/Fs; x = [sin(20*pi*t), sin(20*pi*t+pi/8)];
 

Analog Modulation Example

This example illustrates the basic format of the analog modulation and demodulation functions. Although the example uses phase modulation, most elements of this example apply to other analog modulation techniques as well.
The example samples an analog signal and modulates it. Then it simulates an additive white Gaussian noise (AWGN) channel, demodulates the received signal, and plots the original and demodulated signals.
% Prepare to sample a signal for two seconds, % at a rate of 100 samples per second. Fs = 100; % Sampling rate t = [0:2*Fs+1]'/Fs; % Time points for sampling  % Create the signal, a sum of sinusoids. x = sin(2*pi*t) + sin(4*pi*t);  Fc = 10; % Carrier frequency in modulation phasedev = pi/2; % Phase deviation for phase modulation  y = pmmod(x,Fc,Fs,phasedev); % Modulate. y = awgn(y,10,'measured',103); % Add noise. z = pmdemod(y,Fc,Fs,phasedev); % Demodulate.  % Plot the original and recovered signals. figure; plot(t,x,'k-',t,z,'g-'); legend('Original signal','Recovered signal');
Other examples using analog modulation functions appear in the reference pages for ammod, amdemod, ssbdemod, and fmmod.
 

Digital Modulation [4]

Like analog modulation, digital modulation alters a transmittable signal according to the information in a message signal. However, in this case, the message signal is restricted to a finite set. Using this toolbox, you can modulate or demodulate signals using various digital modulation techniques, listed in Modulation Features of the Toolbox. You can also plot signal constellations.

The topics in this section are as follows:

Representing Digital Signals

To modulate a signal using digital modulation with an alphabet having M symbols, start with a real message signal whose values are integers from 0 to M-1. Represent the signal by listing its values in a vector, x. Alternatively, you can use a matrix to represent a multichannel signal, where each column of the matrix represents one channel.

For example, if the modulation uses an alphabet with eight symbols, then the vector [2 3 7 1 0 5 5 2 6]' is a valid single-channel input to the modulator. As a multichannel example, the two-column matrix

[2 3;  3 3;  7 3;  0 3;] 

defines a two-channel signal in which the second channel has a constant value of 3.

Baseband Modulated Signals Defined

If you use baseband modulation to produce the complex envelope y of the modulation of a message signal x, then y is a complex-valued signal that is related to the output of a passband modulator. If the modulated signal has the waveform

where fc is the carrier frequency and θ is the carrier signal’s initial phase, then a baseband simulation recognizes that this equals the real part of

and models only the part inside the square brackets. Here j is the square root of -1. The complex vector y is a sampling of the complex signal

If you prefer to work with passband signals instead of baseband signals, then you can build functions that convert between the two. Be aware that passband modulation tends to be more computationally intensive than baseband modulation because the carrier signal typically needs to be sampled at a high rate.

Gray Encoding a Modulated Signal

For the PSK, DPSK, FSK, QAM, and PAM modulation types, Gray constellations are obtained by selecting the gray parameter in the corresponding modulation function or method.

Note that Gray-encoding the signal with bin2gray and then modulating it without the gray parameter does not result in a Gray-encoded modulation for the PSK, DPSK, FSK, QAM, and PAM cases. This is due to the modulation functions using symbol values instead of the symbol positions.

As an example, let’s try to make a Gray constellation using PSK modulation. The following examples describe incorrect and correct procedures for making a Gray constellation.

Incorrect Procedure

As an example of how not to do this, this procedure uses bin2gray to Gray-code a signal, and subsequently modulates it. The result is a modulation that is not Gray-coded.

y = bin2gray([0:7],'psk',8); xmap = modulate(modem.pskmod(8),y); k=log2(8); scatterplot(xmap); set(get(gca,'Children'),'Marker','d','MarkerFaceColor','auto'); hold on; for jj=1:length(xmap)         text(real(xmap(jj))-0.15,imag(xmap(jj))+0.15,...         dec2base(jj-1,2,3)); end set(gca,'yTick',(-(k+1)/4:(k+1)/4),'xTick',(-(k+1)/4:(k+1)/4),...         'XLim',[-(k+1)/2 (k+1)/2],'YLim',...         [-(k+1)/2 (k+1)/2],'Box','on','YGrid','on', 'XGrid','on'); hold off; title({'Scatter plot 8-PSK pre Gray encoding',...         'input = bin2gray([0:7],''psk'',8)=[0,1,3,2,6,7,5,4]'}); 

Looking at the map above, notice that this is not a Gray-encoded map; there are cases where adjacent elements differ by more than one bit.

Correct Procedure

The correct procedure uses the pskmod function with the gray parameter.

y = [0:7]; xmap = modulate(modem.pskmod('M',8,'SymbolOrder','Gray'),y); k=log2(8); scatterplot(xmap); set(get(gca,'Children'),'Marker','d','MarkerFaceColor','auto'); hold on; for jj=1:length(xmap)         text(real(xmap(jj))-0.15,imag(xmap(jj))+0.15,...         dec2base(jj-1,2,3)); end set(gca,'yTick',(-(k+1)/4:(k+1)/4),'xTick',(-(k+1)/4:(k+1)/4),...         'XLim',[-(k+1)/2 (k+1)/2],'YLim',[-(k+1)/2 (k+1)/2],...         'Box','on','YGrid','on', 'XGrid','on'); hold off; 

Looking at the map above, notice that this is indeed a Gray-encoded map; all adjacent elements differ by only one bit.

Examples of Digital Modulation and Demodulation

This section contains examples that illustrate how to use the digital modulation and demodulation functions.

Computing the Symbol Error Rate

The example generates a random digital signal, modulates it, and adds noise. Then it creates a scatter plot, demodulates the noisy signal, and computes the symbol error rate. For a more elaborate example that is similar to this one, see Modulating a Random Signal.

% Create a random digital message M = 16; % Alphabet size x = randint(5000,1,M);  % Use 16-QAM modulation to produce y. y=modulate(modem.qammod(M),x);  % Transmit signal through an AWGN channel. ynoisy = awgn(y,15,'measured');  % Create scatter plot from noisy data. scatterplot(ynoisy);  % Demodulate ynoisy to recover the message. z=demodulate(modem.qamdemod(M),ynoisy);  % Check symbol error rate. [num,rt]= symerr(x,z) 

The output and scatter plot are below. Your numerical results and plot might vary, because the example uses random numbers.

num =      83   rt =      0.0166 

The scatter plot does not look exactly like a signal constellation. Where the signal constellation has 16 precisely located points, the noise causes the scatter plot to have a small cluster of points approximately where each constellation point would be.

Combining Pulse Shaping and Filtering with Modulation

Modulation is often followed by pulse shaping, and demodulation is often preceded by a filtering or an integrate-and-dump operation. This section presents an example involving rectangular pulse shaping. For an example that uses raised cosine pulse shaping, see Pulse Shaping Using a Raised Cosine Filter.

Rectangular Pulse Shaping. Rectangular pulse shaping repeats each output from the modulator a fixed number of times to create an upsampled signal. Rectangular pulse shaping can be a first step or an exploratory step in algorithm development, though it is less realistic than other kinds of pulse shaping. If the transmitter upsamples the modulated signal, then the receiver should downsample the received signal before demodulating. The “integrate and dump” operation is one way to downsample the received signal.

The code below uses the rectpulse function for rectangular pulse shaping at the transmitter and the intdump function for downsampling at the receiver.

M = 16; % Alphabet size x = randint(5000,1,M); % Message signal Nsamp = 4; % Oversampling rate  % Use 16-QAM modulation. y = modulate(modem.qammod(M),x);  % Follow with rectangular pulse shaping. ypulse = rectpulse(y,Nsamp);  % Transmit signal through an AWGN channel. ynoisy = awgn(ypulse,15,'measured');  % Downsample at the receiver. ydownsamp = intdump(ynoisy,Nsamp);  % Demodulate to recover the message. z = demodulate(modem.qamdemod(M),ydownsamp); 

Plotting Signal Constellations

To plot the signal constellation associated with a modulation process, follow these steps:

  1. If the alphabet size for the modulation process is M, then create the signal [0:M-1]. This signal represents all possible inputs to the modulator.

  2. Use the appropriate modulation function to modulate this signal. If desired, scale the output. The result is the set of all points of the signal constellation.

  3. Apply the scatterplot function to the modulated output to create a plot.

Examples of Signal Constellation Plots

The following examples produce plots of signal constellations:

The reference entries for the modnorm and genqammod functions provide additional examples.

Constellation for 16-PSK.

The code below plots a PSK constellation having 16 points.

M = 16; x = [0:M-1]; scatterplot(modulate(modem.pskmod(M),x)); 

Constellation for 32-QAM.

The code below plots a QAM constellation having 32 points and a peak power of 1 watt. The example also illustrates how to label the plot with the numbers that form the input to the modulator.

M = 32; x = [0:M-1]; y = modulate(modem.qammod(M),x); scale = modnorm(y,'peakpow',1); y = scale*y; % Scale the constellation. scatterplot(y); % Plot the scaled constellation.  % Include text annotations that number the points. hold on; % Make sure the annotations go in the same figure. for jj=1:length(y)    text(real(y(jj)),imag(y(jj)),[' ' num2str(jj-1)]); end hold off; 

Gray-Coded Signal Constellation.

The example below plots an 8-QAM signal Gray-coded constellation, labeling the points using binary numbers so you can verify visually that the constellation uses Gray coding.

M = 8; x = [0:M-1]; y = modulate(modem.qammod('M',M,'SymbolOrder','Gray'),x);  % Plot the Gray-coded constellation. scatterplot(y,1,0,'b.'); % Dots for points. % Include text annotations that number the points in binary. hold on; % Make sure the annotations go in the same figure. annot = dec2bin([0:length(y)-1],log2(M)); text(real(y)+0.15,imag(y),annot); axis([-4 4 -4 4]); title('Constellation for Gray-Coded 8-QAM'); hold off;

Customized Constellation for QAM. The code below describes and plots a constellation with a customized structure.

% Describe constellation. inphase = [1/2 -1/2 1 0 3/2 -3/2 1 -1]; quadr = [1 1 0 2 1 1 2 2]; inphase = [inphase; -inphase]; inphase = inphase(:); quadr = [quadr; -quadr]; quadr = quadr(:); const = inphase + j*quadr;  % Plot constellation. scatterplot(const,1,0,'*'); hold on; axis([-3 3 -3 3]); title('Customized Constellation for QAM'); hold off;

Using Modem Objects [5]

Modulation of signals is generally done through the use of functions, such as pammod and dpskmod. For PSK and QAM, however, modulation is done through the use of modem objects. This section gives an overview of how you use these objects.

A modem object is a type of MATLAB variable that contains information about the modulation algorithm, such as the name of the modulation class, M-ary number, and the constellation mapping. The object can be operated upon using specific methods to perform certain tasks.

Constructing a Modem Object

To construct PSK and QAM modulator and demodulator objects, use the modem.pskmod, modem.pskdemod, modem.qammod, and modem.qamdemod functions (constructors). See individual reference pages for details.

Managing the Object’s Properties

To view the properties of a modem object, use its disp method, as shown in the following example:

h=modem.pskmod; % Construct a PSK modulator object. h.disp          % Display object properties. 

You can directly assign a value to a property as follows:

h=modem.pskmod(8);    % Construct a PSK modulator object. % Set the 'symbolorder' property of the object to 'gray'. h.symbolorder='gray';  

The properties can also be set to specific values when constructing the object. See reference pages of individual objects for details.

Basic Procedure for Modulating or Demodulating a Signal

Modulating a signal with PSK or QAM involves these steps:

  1. Create a modem object using modem.pskmod or modem.qammod, depending on your modulation type.

  2. Adjust properties of the modem object, if necessary, to tailor it to your needs. For example, you can change the phase offset or symbol order.

  3. Modulate your signal by applying the modulate method of the modem object.

    
    

Demodulating a PSK or QAM modulated signal is performed in a way similar to how you did the modulation except that you use modem.pskdemod or modem.qamdemod objects, and apply the demodulate method of the modem object.

Example Illustrating the Basic Procedure

This code briefly illustrates the steps in the basic procedure previously described.

x = randint(n,1);      % Create a signal source. h = modem.qammod(8)    % Create a modulator object                        % and display its properties. y = modulate(h,x);     % Modulate the signal x. g = modem.qamdemod(h)  % Create a demodulator object                        % from a modem.qammod object                        % and display its properties. z = demodulate(g,y);   % Demodulate the signal y.      

Selected Bibliography for Modulation [6]

[1] Jeruchim, Michel C., Philip Balaban, and K. Sam Shanmugan, Simulation of Communication Systems, New York, Plenum Press, 1992.

[2] Proakis, John G., Digital Communications, 3rd ed., New York, McGraw-Hill, 1995.

[3] Sklar, Bernard, Digital Communications: Fundamentals and Applications, Englewood Cliffs, NJ, Prentice-Hall, 1988.

Special Filters


The Communications Toolbox includes several functions that can help you design and use filters. Other filtering capabilities are in the Signal Processing Toolbox. The sections of this chapter are as follows.

Noncausality and the Group Delay Parameter An implementation issue relating to the group delay of a filter
Designing Hilbert Transform Filters Designing a Hilbert transform filter using the hilbiir function
Filtering with Raised Cosine Filters Filtering data with a raised cosine filter, using the rcosflt function
Designing Raised Cosine Filters Designing a raised cosine filter using the rcosine function
Selected Bibliography for Special Filters Works containing background information about filters

For a demonstration involving raised cosine filters, type showdemo rcosdemo.

Noncausality and the Group Delay Parameter

Without propagation delays, both Hilbert filters and raised cosine filters are noncausal. This means that the current output depends on the system’s future input. In order to design only realizable filters, the hilbiir, rcosine, and rcosflt functions delay the input signal before producing an output. This delay, known as the filter’s group delay, is the time between the filter’s initial response and its peak response. The group delay is defined as

where θ is the phase of the filter and ω is the frequency in radians. This delay is set so that the impulse response before time zero is negligible and can safely be ignored by the function.

For example, the Hilbert filter whose impulse is shown below uses a group delay of one second. In the figure, the impulse response near time 0 is small and the large impulse response values occur near time 1.

Example: Compensating for Group Delays When Analyzing Data

Comparing filtered with unfiltered data might be easier if you delay the unfiltered signal by the filter’s group delay. For example, suppose you use the code below to filter x and produce y.

tx = 0:4; % Times for data samples x = [0 1 1 1 1]'; % Binary data samples % Filter the data and use a delay of 2 seconds. delay = 2; [y,ty] = rcosflt(x,1,8,'fir',.3,delay);

The elements of tx and ty represent the times of each sample of x and y, respectively. However, y is delayed relative to x, so corresponding elements of x and y do not have the same time values. Plotting y against ty and x against tx is less useful than plotting y against ty and x against a delayed version of tx.

% Top plot subplot(2,1,1), plot(tx,x,'*',ty,y); legend('Data','Filtered data'); title('Data with No Added Delay'); % Bottom plot delays tx. subplot(2,1,2), plot(tx+delay,x,'*',ty,y); legend('Data','Filtered data'); title('Data with an Added Delay');

For another example of compensating for group delay, see the raised cosine filter demo by typing showdemo rcosdemo.

Designing Hilbert Transform Filters

The hilbiir function designs a Hilbert transform filter and produces either

  • A plot of the filter’s impulse response

  • A quantitative characterization of the filter, using either a transfer function model or a state-space model

Example with Default Parameters

For example, typing

hilbiir

plots the impulse response of a fourth-order digital Hilbert transform filter having a one-second group delay. The sample time is 2/7 seconds. In this particular design, the tolerance index is 0.05. The plot also displays the impulse response of the ideal Hilbert transform filter having a one-second group delay. The plot is in the figure in Noncausality and the Group Delay Parameter.

To compute this filter’s transfer function, use the command below.

[num,den] = hilbiir  num =     -0.3183   -0.3041   -0.5160   -1.8453    3.3105   den =      1.0000   -0.4459   -0.1012   -0.0479   -0.0372 

The vectors num and den contain the coefficients of the numerator and denominator, respectively, of the transfer function in ascending order of powers of z-1.

The commands in this section use the function’s default parameters. You can also control the filter design by specifying the sample time, group delay, bandwidth, and tolerance index. The reference entry for hilbiir explains these parameters. The group delay is also mentioned in Noncausality and the Group Delay Parameter.

Filtering with Raised Cosine Filters

The rcosflt function applies a raised cosine filter to data. Because rcosflt is a versatile function, you can

This section discusses the use of sampling rates in filtering and then covers these options. For an additional example, type showdemo rcosdemo in the MATLAB Command Window.

Sampling Rates

The basic rcosflt syntax

y = rcosflt(x,Fd,Fs...) % Basic syntax 

assumes by default that you want to apply the filter to a digital signal x whose sampling rate is Fd. The filter’s sampling rate is Fs. The ratio of Fs to Fd must be an integer. By default, the function upsamples the input data by a factor of Fs/Fd before filtering. It upsamples by inserting Fs/Fd-1 zeros between consecutive input data samples. The upsampled data consists of Fs/Fd samples per symbol and has a sampling rate of Fs.

An example using this syntax is below. The output sampling rate is four times the input sampling rate.

y1 = rcosflt([1;0;0],1,4,'fir'); % Upsample by factor of 4/1.

Maintaining the Input Sampling Rate

You can also override the default upsampling behavior. In this case, the function assumes that the input signal already has a sampling rate of Fs and consists of Fs/Fd samples per symbol. You might want to maintain the sampling rate in a receiver’s filter if the corresponding transmitter’s filter has already upsampled sufficiently.

To maintain the sampling rate, modify the fourth input argument in rcosflt to include the string Fs. For example, in the first command below, rcosflt uses its default upsampling behavior and the output sampling rate is four times the input sampling rate. By contrast, the second command below uses Fs in the string argument and thus maintains the sampling rate throughout.

y1 = rcosflt([1;0;0],1,4,'fir'); % Upsample by factor of 4/1. y2 = rcosflt([1;0;0],1,4,'fir/Fs'); % Maintain sampling rate.

The second command assumes that the sampling rate of the input signal is 4, and that the input signal contains 4/1 samples per symbol.

An example that uses the 'Fs' option at the receiver is in Combining Two Square-Root Raised Cosine Filters.

Designing Filters Automatically

The simplest syntax of rcosflt assumes that the function should both design and implement the raised cosine filter. For example, the command below designs an FIR raised cosine filter and then filters the input vector [1;0;0] with it. The second and third input arguments indicate that the function should upsample the data by a factor of 8 (that is, 8/1) during the filtering process.

y = rcosflt([1;0;0],1,8);

Types of Raised Cosine Filters

You can have rcosflt design other types of raised cosine filters by using a fourth input argument. Variations on the previous example are below.

y = rcosflt([1;0;0],1,8,'fir'); % Same as original example y = rcosflt([1;0;0],1,8,'fir/sqrt'); % FIR square-root RC filter y = rcosflt([1;0;0],1,8,'iir'); % IIR raised cosine filter y = rcosflt([1;0;0],1,8,'iir/sqrt'); % IIR square-root RC filter

Specifying Filters Using Input Arguments

If you have a transfer function for a raised cosine filter, then you can provide it as an input to rcosflt so that rcosflt does not design its own filter. This is useful if you want to use rcosine to design the filter once and then use the filter many times. For example, the rcosflt command below uses the 'filter' flag to indicate that the transfer function is an input argument. The input num is a vector that represents the FIR transfer function by listing its coefficients.

num = rcosine(1,8); y = rcosflt([1;0;0],1,8,'filter',num);

This syntax for rcosflt works whether num represents the transfer function for a square-root raised cosine FIR filter or an ordinary raised cosine FIR filter. For example, the code below uses a square-root raised cosine FIR filter. Only the definition of num is different.

num = rcosine(1,8,'sqrt'); y = rcosflt([1;0;0],1,8,'filter',num);

You can also use a raised cosine IIR filter. To do this, modify the fourth input argument of the rcosflt command above so that it contains the string 'iir' and provide a denominator argument. An example is below.

delay = 8; [num,den] = rcosine(1,8,'iir',.5,delay); y = rcosflt([1;0;0],1,8,'iir/filter',num,den,delay);

Controlling the Rolloff Factor

If rcosflt designs the filter automatically, then you can control the rolloff factor of the filter, as described below. If you specify your own filter, then rcosflt does not need to know its rolloff factor.

The rolloff factor determines the excess bandwidth of the filter. For example, a rolloff factor of .5 means that the bandwidth of the filter is 1.5 times the input sampling frequency, Fd. This also means that the transition band of the filter extends from .5 * Fd to 1.5 * Fd.

The default rolloff factor is .5, but if you want to use a value of .2, then you can use a command such as the one below. Typical values for the rolloff factor are between .2 and .5.

y = rcosflt([1;0;0],1,8,'fir',.2); % Rolloff factor is .2. 

Controlling the Group Delay

If rcosflt designs the filter automatically, then you can control the group delay of the filter, as described below. If you specify your own FIR filter, then rcosflt does not need to know its group delay.

The filter’s group delay is the time between the filter’s initial response and its peak response. The default group delay in the implementation is three input samples. To specify a different value, measure it in input symbol periods and provide it as the sixth input argument. For example, the command below specifies a group delay of six input samples, which is equivalent to 6 *8 /1 output samples.

y = rcosflt([1;0;0],1,8,'fir',.2,6); % Delay is 6 input samples.

The group delay influences the size of the output, as well as the order of the filter if rcosflt designs the filter automatically. See the reference page for rcosflt for details that relate to the syntax you want to use.

Example: Raised Cosine Filter Delays

The code below filters a signal using two different group delays. A larger delay results in a smaller error in the frequency response of the filter. The plot shows how the two filtered signals differ, and the output pt indicates that the first peak occurs at different times for the two filtered signals. In the plot, the solid line corresponds to a delay of six samples, while the dashed line corresponds to a delay of eight samples.

[y,t] = rcosflt(ones(10,1),1,8,'fir',.5,6); % Delay = 6 samples [y1,t1] = rcosflt(ones(10,1),1,8,'fir',.5,8); % Delay = 8 samples plot(t,y,t1,y1,'--') % Two curves indicate the different delays. legend('Delay = 6 samples','Delay = 8 samples','Location','NorthOutside'); peak = t(find(y == max(y))); % Times where first curve peaks peak1 = t1(find(y1 == max(y1))); % Times where second curve peaks pt = [min(peak), min(peak1)] % First peak time for both curves

The output is below.

pt =     14.6250   16.6250 

If Fs/Fd is at least 4, then a group delay value of at least 8 works well in many cases. In the examples of this section, Fs/Fd is 8.

Delays of Six Samples (Solid Line) and Eight Samples (Dashed Line)


[1] Communications toolbox: Modulation. MATLAB Support Documentations

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/index.html?/access/helpdesk/help/toolbox/comm/ug/fp45657.html

[2] Modulation Features of the Toolbox, MATLAB Online Support Documentations

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/fp45665.html

[3] Analog Modulation

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/a1041263411.html

[4] Digital Modulation

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/a1041263435.html

[5] Using Modem Objects

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/bqwswmc-1.html

[6] Selected Bibliography for Modulation

http://www.mathworks.com/access/helpdesk/help/toolbox/comm/ug/fp46681.html