Monthly Archives: May 2011

Matlab’s Element-wise Operators

May 17, 2011

Have you ever wanted to multiply or divide the values of two corresponding cells between arrays?  Ever wanted to write one line of code instead of a for-loop? Well now you can. Matlab has special operators to perform multiplication, division and powers between the corresponding cells of two matrices. These operators are useful for simplifying and optimizing code that requires larger matrices. They can replace...

Read more »

Basic Matlab Code Optimization

May 17, 2011
Basic Matlab Code Optimization

As the saying goes, “In a day of work, the best programmers delete more lines of code than they write.” Condensing code usually decreases the run time of a program. Generally, the most time can be saved in the lines of code which are called most often. These slow lines are called bottlenecks. For a beginner it is best to determine the bottlenecks of the...

Read more »

Testing Speed of Matlab Code

May 14, 2011
Testing Speed of Matlab Code

I recently built a computer model for the Soave-Redlich-Kwong (SRK) equation of state in Mathwork’s Matlab. The final program required thousands of iterations of the EOS, so I was interested in optimizing the program to decrease run time. Before optimizing a piece of code, we must have a way of measuring and benchmarking speed for comparison. I used two tools for measuring my software’s speed. Tic-Toc (tic,...

Read more »