Using functions with the vectors and matrices, MATLAB in Mathematics

Using Functions with the Vectors and Matrices:

As MATLAB is written to work with the vectors and matrices, the whole vector or matrix can be passed as an argument to the function. MATLAB will compute the function on every element, and return as a result the vector or matrix with similar dimensions as the original. For illustration, we could pass the vector below, vec, to the abs function in order to get the absolute value of each and every element.

>> vec = -3:4

vec =

-3    -2    -1    0    1    2    3    4

>> abs(vec)

ans =

 3    2    1    0    1    2    3    4

The original vector vec has 8 elements, and as the abs function is computed for every element, the resulting vector also has 8 elements.

This would also be the case for matrices:

>> mat = randint(2,3,[-5,5])

mat =

-5 -1  0

 3  5 -1

>> abs(mat)

ans =

5 1 0

3 5 1

Posted Date: 10/18/2012 4:33:15 AM | Location : United States







Related Discussions:- Using functions with the vectors and matrices, Assignment Help, Ask Question on Using functions with the vectors and matrices, Get Answer, Expert's Help, Using functions with the vectors and matrices Discussions

Write discussion on Using functions with the vectors and matrices
Your posts are moderated
Related Questions
Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Structure Consisting of the Fields A MATLAB can also solve the sets of equations. In this illustration, the solutions for x, y, & z are returned as a structure consisting of th

Write a MATLAB function [d1, u1, l1, c1, r1] = NaiveGaussArrow(d, u, l, c, r) that takes as input the 5 vectors de ned above representing A. This function performs Naive Gauss redu

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

fprintf function - File function: The fprintf function really returns the number of bytes which was written to the file, therefore if you do not want to see that number, suppr

Illustration of Writing to files: Here is the other illustration in which a matrix is written to a file. At First, an arbitrary 2 × 4 matrix is generated, and then it is writt

Complex numbers: A complex number is commonly written in the form z = a + bi here a is known as the real part of the number z, b be the imaginary part of z, and i is √-1

Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal

Dimensions - matrix: The size and length functions in the MATLAB are used to find array dimensions. Length function returns the number of elements in the vector. The size func