Doug’s MATLAB Video Tutorials

December 24th, 2008

MATLAB example: Don’t reinvent the thermometer

My last post talked about finding MATLAB code from other people so that you do not have to reinvent it yourself. Eric, the author of the code I modified, challenged me to create “a new Matlab Central submission that uses the thermometer and a urlread of boston.com to make a new chart like that every day.”

MATLAB Weather in Boston

I am not one to back away from a challenge, so here it is.

The code is fragile, but basically I am using URLREAD to bring in data from weather.boston.com. Once I have the data, I use regular expressions to bring in the data I want. I basically came up with the regular expression by finding the html surrounding the data I was interested in. From there I captured my tokens.

MATLAB RegExp

The rest was just calling the modified thermometer.m code from last week.

I say this is fragile because it is relying on the website keeping the same format. If they change much of anything, this will break. However, until that happens, this is a nice little visualization that shows how you can make just about anything into a datafeed. Are there websites, internal or otherwise, that you would like to have MATLAB read from?

Blog readership goes down significantly over the winter holidays, so I will be taking a week off. I will talk to you all again after the turn of the New Year.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

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