04_CM0268_MATLAB_FNS_GFX

04_CM0268_MATLAB_FNS_GFX - CM0268 MATLAB DSP GRAPHICS 1 93...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CM0268 MATLAB DSP GRAPHICS 1 93 JJ II J I Back Close MATLAB Functions and Graphics We continue our brief overview of MATLAB by looking at some other areas: MATLAB Functions: built-in and user defined Using MATLAB M-files to store and execute MATLAB statements and functions A brief overview of MATLAB Graphics CM0268 MATLAB DSP GRAPHICS 1 94 JJ II J I Back Close MATLAB functions MATLAB makes extensive use of functions (We have seen many in action already) MATLAB provide an extensive set of functions for almost every kind of task. Extensible through toolboxes essentially a collection of functions. Functions can operate on Scalars, Matrices, Structures, sometime in subtly different ways. Soon we will learn how to create our own functions. CM0268 MATLAB DSP GRAPHICS 1 95 JJ II J I Back Close MATLAB Scalar Functions Certain MATLAB functions operate essentially on scalars: These will operate element-by-element when applied to a matrix . Some common scalar functions are: sin asin exp abs round cos acos log (natural log) sqrt floor tan atan rem (remainder) sign ceil CM0268 MATLAB DSP GRAPHICS 1 96 JJ II J I Back Close MATLAB Vector functions Some MATLAB functions operate essentially on a vector (row or column): These will act on an m-by- n matrix ( m 2 ) in a column-by-column fashion to produce a row vector containing the results of their application to each column. Row-by-row operation can be obtained by using the transpose, ; for example, mean(A) . You may also specify the dimension of operation using the second optional parameter. So mean(A, 1) works column-by-column and mean(A, 2) works row-by row . Some common vector functions are max sum median any min prod mean all sort std CM0268 MATLAB DSP GRAPHICS 1 97 JJ II J I Back Close MATLAB Vector Function Examples >> A = rand(4,4) A = 0.8600 0.8998 0.6602 0.5341 0.8537 0.8216 0.3420 0.7271 0.5936 0.6449 0.2897 0.3093 0.4966 0.8180 0.3412 0.8385 >> max(A) ans = 0.8600 0.8998 0.6602 0.8385 >> max(max(A)) ans = 0.8998 >> mean(A) ans = 0.7009 0.7961 0.4083 0.6022 >> mean(A) ans = 0.7385 0.6861 0.4594 0.6236 >> mean(A) ans = 0.7385 0.6861 0.4594 0.6236 >> mean(A, 2) ans = 0.7385 0.6861 0.4594 0.6236 CM0268 MATLAB DSP GRAPHICS 1 98 JJ II J I Back Close Matrix functions Much of MATLABs power comes from its matrix functions, many are concerned with specific aspects of linear algebra and the like (which does not really concern us in this module) Some common ones include: inv inverse det determinant size size rank rank MATLAB functions may have single or multiple output arguments. For example, rank() always returns a scalar: >> A A = 0.8600 0.8998 0.6602 0.5341 0.8537 0.8216 0.3420 0.7271 0.5936 0.6449 0.2897 0.3093 0.4966 0.8180 0.3412 0.8385 >> rank(A) ans = 4 CM0268 MATLAB DSP GRAPHICS 1 99 JJ II J I Back Close Return Multiple Output Arguments size , for example, always returns 2 values even for a vector: >> X = [1 2 3 4]; size(X) ans = 1 4...
View Full Document

Page1 / 35

04_CM0268_MATLAB_FNS_GFX - CM0268 MATLAB DSP GRAPHICS 1 93...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online