260 Ñ Efficient Coding Using Vectorization Technique
A vectorized version for computing z would be as follows:
z = sin(x - y);
In addition to writing your code in vectorized form, if your program satisfies the criteria of
MATLAB Just-In-Time (JIT) accelerator, it can execute as fast as a C program. This chapter
presents some basic concepts for writing efficient MATLAB codes. As we would observe in
this chapter, generally the code written using these techniques is faster, less prone to errors, and
easier to understand. The vector concepts discussed here would prove handy if you plan to use
MATLAB for serious programming applications.
Several concepts in this chapter are illustrated through various examples. Some of the con-
cepts might not be straightforward ...