When running long code streams, waiting in front of the computer watching the program run can be excruciating. Sometimes I find myself doing this if I do not know how long the code will run, or if there will be errors returned. (I also sit in front of the computer because I enjoy watching cat gifs and the old school de-fragmentation screens, so who knows…) But you don’t have to! Go out and accomplish something else while your computer chugs away. With the useful command sendmail, we can send messages to our email or phone with some simple commands. Through this post, I’ll share some sample .m files that we commonly use to notify ourselves of code completion or errors.
In the last article I wrote about managing your path in Matlab, I covered some of the functions that deal with the search path, including path, matlabroot, addpath, rmpath and genpath. These functions provide a solid base for viewing, adding and removing directories from your search path. In this article, I will explain how to use several more functions that deal with your search path, including functions that make changes which persist after ending your Matlab session. Continue reading
Management of your search path in Matlab is an important skill that every Matlab programmer should have. Your search path is the ordered set of directories that Matlab uses to find a function that you call. Being aware of your search path is a good habit, especially if you are working with multiple versions of the same code. In this post and the following post, I will describe how to use Matlab to modify your search path. Continue reading
What separates Matlab from many other programming languages is the ability to vectorize code. Vectorization allows a programmer to write code that is more intuitive, more concise, and often faster than using standard for, while and if statements. If you have to do a large data processing task or need to create real-time application that does a large number of mathematical operations, vectorization is often a good option. However, vectorization is not always the faster alternative for time-sensitive tasks. I created tests for six tasks and compared the amount of time needed to run the vectorized and non-vectorized code. The results were mixed, showing a decrease in running time for vectorized code on some tasks and a increase in running time on other tasks. Tests involving mathematical operations ran faster using vectorized code, while tests involving conditional operators and vector creation ran faster for non-vectorized code.
|Test||Time Ratio (Vec/Non-Vec)|
Number formatting can be crucial when presenting data. While a simple topic, Matlab has provided many built in commands that can make your analysis easier. This tutorial will cover round, fix, ceil, floor and format.