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
Persistent Variables: Generally, whenever a function stops executing, then the local variables from that function are cleared. That means that each and every time a function i

Operation on file: We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is

Tracing: Sometimes, when a program has loops and/or selection statements and is not running properly, it is helpful in the debugging process to know exactly which statements h

Functions which complete a task without returning Values: Most of the functions do not compute values, but instead of accomplish a task like printing formatted output. As thes

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

Example of Function stubs: The three functions have not so far been written, though, therefore the function stubs are put in place so that the script can be executed and teste

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

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

Example of Vectorizing: Likewise, for an operation on a matrix, a nested loop would be needed; for illustration, supposing a matrix variable mat: [r c] = size(mat); for

Opening and Closing a File: The Files are opened with the fopen function. By the default, fopen function opens a file for reading. If the other mode is preferred, a permission