Vectorizing, MATLAB in Statistics

Vectorizing:

In most of the cases in MATLAB, loops are not essential. As MATLAB is written specifically to work with the vectors and matrices, most operations can be completed and functions can be called with the vectors and matrices. However, the term vectorizing is used in MATLAB for rewriting code by using loops in a traditional programming language to the matrix operations in MATLAB.

In many programming languages, whenever performing an operation on a vector, a for loop is used to loop through the whole vector. For illustration, in MATLAB supposing that there is a vector variable vec:

for i = 1:length(vec)

% do something with vec(i)

end

Posted Date: 10/19/2012 3:53:17 AM | Location : United States







Related Discussions:- Vectorizing, Assignment Help, Ask Question on Vectorizing, Get Answer, Expert's Help, Vectorizing Discussions

Write discussion on Vectorizing
Your posts are moderated
Related Questions
Program of Persistent variables: The program below elaborates this. The script calls a function func1 that initializes a variable count to 0, then increment it, and print the

Advanced File Input and output: Where 'format' involves the conversion characters much like those used in the fprintf function. For illustration, to read the file 'subjexp.dat

MENU Function: The MATLAB also has a built-in function known as menu which will display a figure Window with push buttons for the choices. The very first string passed to the

Index vector: The index vector is then used as the indices for original vector. To get grades vector in ascending order, the indices used would be grades (2), grades (5), and

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

Properties of the text box - graphics objects: By using get will show properties of the text box, the illustration is as shown below: >> get(thand)   BackgroundColor

Logical errors: The Logical errors are more complicated to locate, as they do not result in any error message. The logical error is a mistake in reasoning by the programmer, b

Logical Built-In Functions: There are built-in functions in the MATLAB which are useful in conjunction with vectors or matrices of all logical true or false values; two of the

Vectors of nested structures: The Combining vectors and nested structures are possible to have a vector of structures in which several fields are structures themselves. Here i

WHILE Loops: The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action w