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

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

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

Core Objects: The Core Objects in MATLAB are the very fundamental graphics primitives. The description can be found under the MATLAB Help: Under the Contents tab, click the Ha

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

Statistics There are numerous statistical analyses which can be executed on data sets. In MATLAB software, the statistical functions are in the data analysis help topic known a

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

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

Function polyval - interpolation: The function polyval can then be used to compute the polynomial at particular values. For illustration, we could compute at every value in th

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