Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

File Exchange Pick of the Week

October 3rd, 2008

Intruder Alert!

Jiro's pick this week is Intruder Detection by David Leffingwell, a fellow MathWorker.

I really like examples that involve hardware because they are flashy and you can physically see things happening. The MathWorks provides several toolboxes for connecting to various types of hardware, ranging from data and image acquisition boards to stand alone instruments.

What I like about this nifty demo is that it combines both Data Acquisition Toolbox and Image Acquisition Toolbox to do motion and noise detection. Once the program detects some motion or noise, it starts recording video and audio for a specified number of seconds. It's also very simple to try out, because it only requires an off-the-shelf webcam (I'm using a Logitech USB webcam) and a soundcard which is already installed on my laptop.

Take a look at this short recording I made. I tested this out at a hotel in Kalamazoo, MI (I was there for a seminar).

Comments?

Anybody doing hardware interfaces? Tell me about it here. I would be interested in hearing about simple examples that you can do with a webcam or a sound card (so that I can try it out!). And please post them on the File Exchange!


Get the MATLAB code

Published with MATLAB® 7.6

September 25th, 2008

Postcard from Doug

Even though I have moved over to the Video blog [click here] I wanted to give a quick update on the winner of the data exploration puzzler we did a while back.

It turns out that the winner, Arthur, already had a t-shirt from when Loren visited MIT. So instead, he sent me a resume, applied and got a job at The MathWorks. He started Monday.

Being active on MATLAB Central is beneficial in and of itself, but it can also lead to careers with us. Jiro and Brett were already well known for their MATLAB cleverness through MATLAB Central before they started here.

If you want a job at The MathWorks click here and send your favorite blogger your resume. MATLAB Postcard

Be sure to visit the new video blog and subscribe so that you know when I put up new videos, tutorials and puzzlers.

September 19th, 2008

De do do do, de dah dah dah…

Brett's Pick this week is Morse, by Fahad Al Mahmood.

Last week I blogged about how to make MATLAB talk. This week, we can look at how to make it speak Morse code!

I recall fondly being an undergrad engineering student, and being required to learn Morse code as a prerequisite to throwing my name into contention to drive a solar-powered car in a long-distance race. I never got very good at it (Morse code, that is), and have forgotten everything I once knew. (Except for S's and O's...we all seem to know them!)

Fahad's MORSE is pretty cool; it renders a string of characters as an audible series of dots and dashes, making translating words into Morse code trivially easy. Now if someone would just write a MATLAB program that listens to a series of dots and dashes and translates it back to text. Any takers?

Oh, and there's a t-shirt in it for the first person to post in the comments to this blog the (exact!) message encoded in the video above!


Get the MATLAB code

Published with MATLAB® 7.6

September 16th, 2008

New location for Doug’s videos!

I have moved. [NEW LOCATION]

Today, Brett, Bob and Jiro have completed their inheritance of Pick of the Week blog. There is a fine heritage of Applications Engineers running the Pick of the Week blog. Scott Hirsch and I started it nearly five years ago with this post. [click here]

With the three amigos taking over, I am now freed up to dedicate time to this new blog. Doug's MATLAB Video Tutorials. You can expect the same content with original videos, puzzlers, tutorials and answers to user questions.

The first video is about memory allocation in MATLAB. In this two minute video, I show that a statement like Y = X; does not increase MATLAB's memory usage, even for large variables.

Come see the video at the new location and be sure to subscribe to the new blog.

Thanks,

Doug

September 12th, 2008

Making MATLAB Talk

Brett's Pick this week focuses on functionality rather than on a single file.

For a project I'm currently playing around with, I recently decided that I wanted to make my computer talk, and to use MATLAB to control it. A brief search of documentation didn't return any hits that looked promising--MATLAB doesn't really provide any mechanism for generating speech. Looking at the File Exchange (keyword "speech"), though, proved fruitful. In fact, selecting which of the several submissions to use was the most difficult part of the problem.

Chronologically, the first "speak" mfile I found was from Fahad Al Mahmood, submitted back in 2004. (Indeed, Fahad's file was selected as a Pick of the Week, back in '04.) But that file uses a call to Excel, and doesn't provide for a lot of control over the generated speech.

Fahad's submission was closely followed by Iari-Gabriel Marino's no-frills ActiveX version of TTS (text-to-speech).

Wolfgang Garn's 2006 submission includes a function called text2speech that allows a user to control pitch, to insert pauses, and to add emphasis to words.

And Siyi Deng followed up in 2007 with another version of TTS that optionally allows the user to write WAV files, to control the speed of the voice, and to list available voices.

You gotta love the File Exchange--thanks for these great submissions, Fahad, Iari-Gabriel, Wolfgang, and Siyi!

Anyone have any good stories to share about using MATLAB to speak, or doing speech recognition in MATLAB? We'd love to hear from you.


Get the MATLAB code

Published with MATLAB® 7.6

September 9th, 2008

Advanced MATLAB: File name processing from directory listing

Very often MATLAB users want to be able to process a set of files from a directory. In this video, I show how you can look through a directory seeking files of the form “data###.dat” and then returning the “###” as a number with any leading zeros removed. This makes use of regular expressions, but does not explain their theory much at all.

Video Content

iconFiles.jpg

This is not the first time this kind of thing has been discussed. Check out Loren’s take, or Steve’s take from their blogs.

September 5th, 2008

Olympic medals

Bob's pick this week is Summer Olympic Medals 1896-present by Bill McKeeman.

The data source is Wikipedia, which Bill references. I find his plots much more interesting than staring at tabular data. His approach to coding this example underscores how many ways there can be to solve a problem. I know my own approaches have varied widely over the years, usually dictated by time spent and knowledge level at the time.

Comments?

How do you approach analysis problems like this? Tell us about it here.


Get the MATLAB code

Published with MATLAB® 7.7

September 3rd, 2008

How our developers make MATLAB faster

Last week, we had a Puzzler [click here] that could be developed faster and easier by using the Image Processing Toolbox. Some people used the toolbox, and some did not. As the conversation in the comments continued [click here] we scaled the problem up by solving the problem thousands of times. At this scale, a bottleneck in RMFIELD, which is used by REGIONPROPS, noticeably slowed the Image Processing based code.

It did not take long for Steve Eddins, of Image Processing fame, to notice this conversation. Soon, one of the developers on the team, Inpakala, worked up a solution that speed up the code 70%!

It is too late for this speed optimization to make the 2008b release of MATLAB, but it should make 2009a once all testing is done. This is a case of writing code clean and clear at first and only then doing optimization where the bottlenecks appear. I would like to talk about this solution, and use some MATLAB tools to explore it.

Here is the crux of the problem, in its simplest form:

im = round(rand(100));
for i = 1:1000
    old = regionprops(im,'area');
end


Looking at the Profiler report for this simple code, [Click here for a video on the Profiler]

MATLAB profiler

we can quickly find the slowest part of each m-file until we hit the culprit.

MATLAB profiler

arrow.jpg
MATLAB profiler

arrow.jpg
MATLAB profiler

By looking at the slowest line each time, Inpakala found that the slow line of code was from the use of STRMATCH, which is called by RMFIELD. Since that file is not something she can easily modify, just like any other MATLAB user, she needed to find a different way of writing the code she could control.

Lets look at her modified code using the file comparison tool:

MATLAB file comparison tool

We find that around the trouble line, Inpakala mde the following changes.

MATLAB file comparison tool

The analysis of the actual code changes made is really beyond the scope of this entry, but basically she changed two lines of code (in red) and added three others (in green) along with a new ten line subfunction (not shown).

In the final analysis: the code got longer, more complicated and faster. Notice the code started with the simplest code that would work, and only when optimization was needed was it attempted. In the end, this optimization knocked 70% off of the runtime for REGIONPROPS.

MATLAB profiler

Do you find bottlenecks with the profiler? If you find a bottleneck in MATLAB code that could be improved, don’t be shy! Tell us about it!

September 2nd, 2008

Interview about making MATLAB Videos

Several people have asked about how I make these MATLAB videos. Recently the folks that make Camtasia interviewed me about the videos making process. Those of you that are interested in a look behind the curtain can read the full interview and video making tips here:

Interview about Camtasia and MATLAB.

August 29th, 2008

Smooth MATLAB Graphics

Jiro's pick this week is MYAA by Anders Brun.

A few months ago, I wrote a post for Loren's Art of MATLAB blog about creating publication-quality graphics. That post was about controlling various properties of graphics objects to make the visualization a higher quality.

Another way of making better-looking graphics is to use anti-aliasing. Anti-aliasing provides a smoother look to the lines drawn on the screen. PCs use anti-aliasing to make the fonts smoother. With MYAA, you can easily anti-alias your MATLAB graphics. This is great for both on-screen presentation as well as MATLAB publishing (this blog post is a published document).

Original Plot

With the regular screen resolution, you can see the aliasing. It is most apparent with diagonal lines.

membrane

Anti-Aliased Plot

Anti-aliased plot looks much smoother. MYAA supersamples the plot (as an image) and then resizes it (via a filtering method), giving an anti-aliased look.

myaa

If we take a closer look at the two images, you can see the anti-aliasing effect.

im1 = imread('antialias_01.png');
im2 = imread('antialias_02.png');
subplot(1,2,1);
imshow(im1(100:150, 300:350, :));
title('Original');
subplot(1,2,2);
imshow(im2(100:150, 300:350, :));
title('Anti-Aliased');

More Features

MYAA has additional features that make it a very handy tool. For example, you can specify the supersampling factor to provide an even smoother look. The tool also has a nice interactive feature where you can refresh the graphics (after zooming or rotating the original plot) or zoom in and out with the anti-aliased plot.

Finally, I like how Anders has been quickly updating his entry in response to the user feedback. He posted this file early this month, and he has already updated several times, making this tool more user-friendly.

Comments

Do you ever make presentations directly from MATLAB? What are some tricks you employ to make MATLAB a presentation tool? As a starter, I once created a MATLAB animation player for displaying animations. Tell us about your stories here.


Get the MATLAB code

Published with MATLAB® 7.6


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Doug: Gamal, That is something that can be done. Do you have the Data Acquisition toolbox? What have you tried, can...
  • Gamal: Dear Sir, I am working in a project that i use an Analogue to digital converter HW to transfer analogue...
  • Berdakh Abibullaev: Great! This is very convinient to use. But I use matlab codes for opening the data and...
  • jiro: Mahmood, It’s probably best to ask the author of the tool for specific questions regarding the...
  • Mahmood: Hi there, when I run this program application, it gives me the following error ??? Error using ==>...
  • Brett: Hi M, Back from vacation…just downloaded DEMORSE, and ran it on the WAV file I created for this post....
  • Quan Quach: Doug is my favorite MathWorks blogger. Loren is also my favorite. That Mike guy not so bad. So Arthur got...
  • Doug: Maram, You might want to look at the Database toolbox. http://www.mathworks .com/products/databa se/ Doug
  • Bob: Nayaki, if you need additional help using a File Exchange submission, you might try contacting the author. You...
  • maram: hi, I have a question I have a matlab code and i want to read a data from SQL server database to use it in...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.

Related Topics