MATLAB Guide

Chapter 21: Tricks and Tips

Our approach in this book has been to present material of interest to the majority of MATLAB users, omitting topics of more specialized interest. In this chapter we relax this philosophy and describe some tricks and tips that, while of limited use, can be invaluable when they are needed and are of general interest as examples of more advanced MATLAB matters.

21.1 Empty Arrays

The empty matrix [], mentioned in several places in this book, has dimension 0-by-0. MATLAB allows multidimensional arrays with one or more dimensions equal to zero. These are created by operations such as

   <span class="unicode">?</span> 1:0   ans =      Empty matrix: 1-by-0   <span class="unicode">?</span> zeros (2,0)   ans =      Empty matrix: 2-by-0   <span class="unicode">?</span> ones (1,0,3)   ans =      Empty array: 1-by-0-by-3

Operations on empty arrays are defined by extrapolating the rules for normal arrays to the case of a zero dimension. Consider the following example:

   <span class="unicode">?</span> k = 5; A = ones(2,k); B = ones(k,3); A*B   ans =        5    5       5        5    5       5   <span class="unicode">?</span> k = 0; A = ones(2,k); B = ones(k,3); A*B   ans =...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Waveplates and Retardation Plates
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.