When we launched Trendy, you could only grab one data point per trend. One of our very first plots, which was created as simple example, tracks the daily high and low temperatures in Anchorage, Alaska. Naturally, this plot requires two data points for each day: the daily high in Anchorage, and the daily low in Anchorage. But the thing is, these two numbers both come from the same web page. That means we’re visiting the same page twice to get two numbers. Seems a shame, eh? It would be much nicer if we could just visit the page once and extract both numbers.
That’s why we recently added the ability to grab and store multiple data points (i.e. vectors) per day in a single trend. In keeping with our weather example, here’s the first vectorized trend I created: Vectorized High/Low for Anchorage. Plotting is very straightforward. The data for vectorized trends is stored as the rows of a matrix. So if you plot time against data, you get a nice time series plot of each piece of data. Here is the resulting high-low temperature plot and the accompanying code.
ylabel('Temperature (deg. F)')
title('High/Low Temperatures in Anchorage, Alaska')
Now let’s move on to something a little more ambitious. Suppose you wanted to track the standings of every American major league baseball team. Before vectorized trends, you would need to create 30 different trends, one for each team. Patrick Kalita has done this. At the time he didn’t have any choice, but it must have taken him a while. Using this data, Patrick is tracking the standings for each division in the major leagues. I want to call your attention to the fact that he has carefully aligned each team’s line color with their real-life team colors. Nice work Patrick!
I wanted to try to do something similar: track the winning percentage of all the major league teams. Now I can do that in a single trend. With all the data in one place, I can easily show all the teams in a single plot. But maybe more important, it’s easier for me to analyze the data. For instance, here’s a plot where I calculate the longest current winning and losing streaks. Note the freakish correlation between the Nationals and the Yankees.
Cleverest usage of vectorized trends so far: Aurelien’s Reasons why MathWorks should have an office in my village. It’s a comparison of the weather differences between Meudon (near Paris) and Corbières. It looks like Corbières is winning!
10 CommentsOldest to Newest
Thanks for the compliment Ned.
I was thinking about a nice feature that I would like to see in Trendy : the ability to embed the graphic in a website. For example in youtube you can get a code to embed any video in your own website.
Hi there Aurélien,
That feature (being able to embed items from Trendy) is something we’re looking at. In the short term, the plot images from Trendy are static and can be linked to directly. If you select your plot image in your browser you can usually find a right-click menu selection that will give you the image location, which can be embedded in a tag like so:
<img src= “http://www.mathworks.com/matlabcentral/trendy/images/plots/plot_894.png” />
Notice the id in the image file name? It’s the id number from your plot. This is available until we replace it with something simpler and more useful. I hope that will hold you till then!
Have a good day!
Thanks for the shout-out, Ned.
Also, I just have to point out that the line for the Rockies in that plot looks freakishly like … A MOUNTAIN! Coincidence?! … yeah, probably.
I’m glad you mentioned that Patrick. I noticed that too and was going to say something about it. Also worthy of note: the correlation between the Yankees and the Nationals couldn’t have survived this weekend, since they were playing each other. Result: Yankees up, Nationals down.
Thanks Luke for the answer.
If I have enhancements to suggest for Cody or Trendy , what is the official way to submit them?
Hi Aurélien! Please do post your suggestions for enhancements here as comments to our community blog posts. We created this blog as a way to enable conversations between our community members and MathWorks. I hope that other readers will jump into these conversations and share their thoughts on topics as well. Thanks for bring up this great question! :-)
Thanks Helen. I prefer waiting a topic on Cody before submitting my remarks.
Great! Now I can do the FEX50 trend I’d mentioned before. Except that now I find that my trend is only saving 53 of 100 data points as valid numbers – the rest come out as NaNs. This doesn’t happen when I run code locally. Is there an issue here? The trend id is 1519. Thanks.
That looks to me like a bug. I’ll work on that and get back to you.
It’s a serialized string length limit problem. Our use cases didn’t take into account vectors with more than ~50 elements. As a work around I would split your trend into 2 or 3 trends (agreed…this is not optimal) and we’ll log the issue and get a fix out in the next release!
OTOH I’m very please that our users are pushing our limits so soon. Thanks!