Illustration of indexing, MATLAB in Statistics

Illustration of Indexing:

Though, rather than of creating the index vector manually as shown here, the process to initialize the index vector is use to a sort function. The algorithm is as shown below:

  •  Initialize the values in index vector to be the indices 1,2, 3, ....
  •  Use any of the sort algorithm, but compare the elements in the original vector by using the index vector to index into it (example, using grades (grade_index(i))).
  •  Whenever the sort algorithm calls for replacing values, replace the elements in the index vector, not in the original vector.

The function which implements this algorithm is as shown below:

1481_Illustration of Indexing.png

For illustration, for the grades vector as given:

>> clear grade_index

>> grade_index = createind(grades)

grade_index =

2 5 1 6 4 3

>> grades(grade_index)

ans =

70 80 85 91 95 100

Posted Date: 10/22/2012 7:52:17 AM | Location : United States







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

Write discussion on Illustration of indexing
Your posts are moderated
Related Questions
Data structure layers: There are many layers in this variable. For illustration,  cyls is the whole data structure, that is a vector of structs  cyls(1) is a separate

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

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

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

Debugging Techniques: Any error in the computer program is called a bug. This word is thought to date back to the 1940s, whenever a problem with an early computer was found to

Sorting Strings: For the matrix of strings, the sort function works exactly as formerly for numbers. For illustration, >> words = char('Hi', 'Hello', 'Howdy', 'Goodbye', '

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

Example of Core objects: The one core graphics object is a line that is also what the plot function produces. Here is an illustration of generating a line object, altering som

Example of customizing plots: As the other illustration of customizing plots, the pieces of a pie chart can be "exploded" from the rest. In this situation, the two vectors are

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