Stuart’s MATLAB Videos

Watch and Learn

MATLAB example: Don’t reinvent the thermometer

Posted by Doug Hull,

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 http://www.boston.com/weather/. 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.

1 views (last 30 days)  | |

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.