06 November 2021

MATLAB denouement

My last update regarding Matlab was that I had just one more plot to make. Would I manage to plot the fossil samples on my scatterplot? Well! Yes and no.

I tried it, and without help I didn't manage; I got the modern samples on the plot, but not the fossil ones, and not the key. That was clearly not good enough! And I knew it would take me forever to sort it out myself, but I decided I didn't have forever and I needed help. My first point of call was my colleague Yueng, who had helped me before. But she was busy. She was willing, though, to look at it the week after. I did want to publish my results ASAP though, so I decided to try Martin. He is actually the module leader of the module for which I need this. He directly benefits from it if I get my stuff sorted on time! And I know he is a Matlab wizard. So I asked him. And I got an email in the morning saying he was willing to look at it; he had an initial look, and already noticed the script was looking for something in the input file that wasn't there. But he said he had to go and teach now, and would have another look in the afternoon.

The script had given me the following error message:

Unable to perform assignment because the left and right sides have a different number of elements.

Error in f_nmdsPlot_mod_and_fos_2021 (line 125)

       hdl(l) = plot(scores(I, 1), scores(I,2), 'd', 'markersize', 10, ...

That was all very well, and it did vaguely point in the right direction, but I had no idea what the script was either missing or finding superfluous. But now that Martin had pointed it out, I knew where to look. That input file I have made myself; I can work with that! So while he was teaching I improved my import file, which was not as simple as I had hoped; when I had sorted it, Matlab decided single-handedly to change one column of data to "NaN". Luckily, it accepted me manually putting the values back in. And then the script ran. Hurray! I mailed Martin back saying that he inadvertently had already solved the problem, and thanked him profusely. I could move on now.

The way it ran would not get me a prize for beauty, but I didn't mind that. For instance, I had spurious entries in the key (see my earlier results), but it is child's play to just remove these in graphic software. The colours were not the best, so I changed these too. But then I could go and finalise my assignment!

To my surprise, I received another email in the afternoon. Martin had tidied up my script. For instance, the spurious key entries were now gone. And he had packed all the separate commands into one script that automatically calls them up. That makes it a lot quicker to run the whole thing. I should not be surprised at that level of perfectionism, but I just hoped he hadn't spent much time on this as without these tweaks, the work was good enough. By my standards, anyway. And my first attempt at running his new shiny script ended up in another error message. Oh dear.

I waited until a time I wasn't very tired and/or distracted, and gave it another go. And I managed to make it run! Smoothly, as expected. I still played a bit with the colours as several sample groups had a rather similar shade of green, but then I finalised a plot and put that in the actual assignment. And then I was ready to publish it! The students have a session to work with this data in late November. They might be ready by that time, and not need it! But I feel I have taken the imperfect data we gathered on the fieldtrip (you want a bit more time on things like this) and turned it into a useful assignment. I hope the students agree with me!

A tidy plot with modern and fossil samples! 


No comments:

Post a Comment