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
Example of Symbolic Expression When there is more than one variable, the MATLAB selects which to solve for. In the illustration below, the equation ax 2 + bx = 0 is solved. Th

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Animation: In this part we will observe a couple of ways to animate a plot. These are visuals, therefore the outcomes can't really be shown here; it is essential to type these

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Counting in a While Loop: Whenever it is not known ahead of the time how many values will be entered into the script, it is often essential to count the number of values which

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

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

Writing variables to a File: The save command is used to write variables to a file, or to append the variables to a MAT-file. By the default, save function writes to a MAT-fil