Example of vectorizing, MATLAB in Statistics

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 row = 1:r

for col = 1:c

% do something with mat(row,col)

end

end

typically in MATLAB, this is not essential. The Numerical operations can be completed on whole vectors or matrices. For illustration, let's say that we want to multiply each and every element of a vector v by 3, and store the outcome back in v, here v is initialized as shown below:

>> v = [3 7 2 1];

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







Related Discussions:- Example of vectorizing, Assignment Help, Ask Question on Example of vectorizing, Get Answer, Expert's Help, Example of vectorizing Discussions

Write discussion on Example of vectorizing
Your posts are moderated
Related Questions
Illustration of nested for loops and the if statements: For illustration,when the file contains: 33   -11  2  4      5   9 22     5  -7  2     11    3 the outco

Combining Nested FOR Loops and the IF Statements: The statements inside a nested loop can be any of the valid statement, involving any selection statement. For e.g., there can

Example of Mode When no value appears more often than any other, the smallest value in the vector will be the mode of the vector. >> shortx = [2 5 1 4]; >> mode(shortx

#qYou will need to examine two of the nine sections of data: one section of qualitative data (choose either Gender or Position) one section of quantitative data (choose either Intr

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

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

fscanf function - file function: The fscanf reads matrix variable mat columnwise from the file specified by fid. The 'format' involves conversion characters much similar to th

Roots function - Polynomials: The roots function in MATLAB is used to find the roots of an equation represented by a polynomial. For illustration, for the mathematical functio

Illustration of Indexing into vectors of structures: For illustration, the function to print the information from packages has been modified therefore in addition to the vecto

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