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
Run-time or execution-time error: The Run-time, or execution-time, errors are found whenever a script or function is executing. With most of the languages, an illustration of

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

Curve Fitting: The data is fundamentally either discrete or continuous. In most of the applications, data is sampled, for illustration, The temperature recorded every ho

Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of

Illustration of Binary search: An illustration to search for the key of 91 in the vector is as shown below: The table below shows what will happen in each iteration of

Nested for Loops: The action of a loop can be any of the valid statement(s). Whenever the action of a loop is the other loop, this is known as nested loop. As an illustrati

Generic code for Reading from Files: The generic code to complete this is as shown below:   fid = fopen('filename'); if fid == -1    disp('File open not suc

Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

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

Illustration of Nested loops: Running the script shows the output: >> printstars ***** ***** ***** The variable rows identifies the number of rows to print, and