02 May 2016

MATLAB magic

Sometimes progress is slow! In February I started to try to learn Matlab. I then had to shelve my attempts for a while as other things demanded attention. But I'm back on it! I explained I tried to calculate a biodiversity index in Matlab, and tried to plot data in a triangular plot.

I needed help with the biodiversity index. I didn't know how to get it to work, but luckily my colleague Suzie was willing to help. Soon we had a script that could successfully calculate values for some test data. As I wanted to understand what we had done, I brushed up on my general knowledge; mainly through an online tutorial. With that and the general Mathworks page full of resources I managed independently to make it write the results to an excel file. Success! But it was harder to get it to run a proper data set. The iterative loop was not coded properly, which meant that a variable was defined in the wrong place, and all went pear-shaped. But she helped me sort this out.

The triangular plot was rather challenging for a newbie. Another colleague, Yueng, coded it for me. Of course, when I tried it myself on my machine it didn't work properly, but soon I managed to get results (see below). Great! I managed to tweak the script since to have better axis labels and legend placement. I also managed to plot a second data set in, in stars. I'm not done yet, though; the graph is such that empty circles are raw values and filled circles are averages; they key does not explain that. And the second set of samples isn't in the legend either (you can't have two legends). I'll have to figure out how to work around that! It will be hard, but once I manage I've properly learned something. Imagine what I could use that for! Matlab can be used for all kinds of calculations and plots. That will stay useful forever!


No comments: