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
Illustration of tracing a error: The one way of following the flow of function, or tracing it, is to use the echo function. The echo function, that is a toggle, will show each

Editor/Debugger: The MATLAB has numerous useful functions for debugging, and debugging can also be completed through its editor, which is known as the Editor/Debugger. Typi

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

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

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

The IF Statement: The if statement selects whether or not the other statement, or group of statements, is executed. The common form of the if statement is as shown below: i

Nested Structures: The nested structure is a structure in which at least one of the members is itself a structure. For illustration, a structure for the line segment may co

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

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

Illustration of Customizing plots: Illustration, the bar and barh functions by the default place a width of 0.8 between bars. Whenever called as bar(x,y), the width of 0.8 is