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
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

Representing Logical true and False: It has been stated that expressions which are theoretically true really have the integer value of 1, and expressions which are theoretical

Need of a nested loop: How would we sum each individual column, rather than getting an overall sum? Answer: The programming technique would need a nested loop in whi

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti

Help function: Function is computing the two values, there are two output arguments in the function header (i.e., area & circum), that are placed in the square brackets [ ]. A

Median The median is defined only for a data set which has been sorted first, that means that the values are in order. The median of a sorted set of data values (n) is defined

Determine sequence weights for the sequences ACTA, ACTT, CGTT, and AGAT in problem 1 by using Thompson, Higgins, and Gibson method a) compute pairwise distances between sequences

Example of Median For the vector [1 4 5 9 12 33], the median is the average of the 5 & 9 in the middle: >> median([1 4 5 9 12 33]) ans =     7

Illustration of Median When the vector is not in sorted order to start with, the median function will still return the right answer (it will sort the vector automatically). For

Input in a While Loop: The script below repeats the procedure of prompting a user, the reading in a positive number, and echo-printing it, as long as the user properly enters