Fundamentals of Signals and Systems

Appendix A: Using MATLAB

MATLAB is a useful and widespread software package developed by The Math Works Inc. for numerical computation in engineering and science. MATLAB is easy to use and can be learned quickly. It comes with very good manuals. The purpose of this appendix is simply to provide a brief overview on how to use MATLAB and present some of its capabilities.

In order to perform computations, one can use the command line, or write a program as a script, called an M-file, in MATLAB's own language. This language is well suited to handling large vectors and matrices as single objects. Consider the following script:

% Simple matrix-vector computations...% Define 3x3 matrix AA=[1 2 3; 4 0 -2; 1 2 -3]% Define 3x1 vector xx=[-1; 0; 1]% Compute eigenvalues and eigenvectors of A[T,L]=eig(A)% L is the diagonal matrix of eigenvalues,T is the matrix of eigenvectors% Diagonalize matrix A with TD=inv(T)*A*T% Compute the product A.xy=A*x

Also, mathematical functions can be used on an entire vector or matrix in one shot. This greatly simplifies the code. For example, the following script plots ten cycles of a sine wave in only three lines.

% time vectort=0:.01:1;y=sin(20*pi*t);plot(t,y)<span class="beginpage"> pagenum="646"><a name="2206"></a><a name="IDX-646"></a></span>

The help command tells the user how to use any other command. For instance,

  help eig    EIG    Eigenvalues and eigenvectors.E = EIG(X) is a vector containing the eigenvalues of a squarematrix X.[V,D] = EIG(X) produces a diagonal matrix D of eigenvalues and afull matrix V whose...

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: Cylindrical Lenses
Finish!
Privacy Policy

This is embarrasing...

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