Illustration of indexing, MATLAB in Statistics

Assignment Help:

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


Related Discussions:- Illustration of indexing

Example of nested functions, Example of Nested functions: For illustra...

Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of

Areacirc function, Areacirc function: The areacirc function can be cal...

Areacirc function: The areacirc function can be called from the Command Window as shown here, or from a script. Here is a script which will prompt the user for the radius of o

Illustration of input in a for loop, Illustration of Input in a for loop: ...

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

Opening and closing a file, Opening and Closing a File: The Files are ...

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

Bus311.., #qYou will need to examine two of the nine sections of data: one ...

#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

Lower level file i/o functions, Lower Level File I/O Functions: Whenev...

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

Create a custom chi-square function in matlab, Introduction and Purpose ...

Introduction and Purpose In the lectures and tutorials you have been introduced to a number of probability distributions. You have also learned that modelling any system (such

Nested structures, Nested Structures: The nested structure is a struct...

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

Persistent variables, Persistent Variables: Generally, whenever a func...

Persistent Variables: Generally, whenever a function stops executing, then the local variables from that function are cleared. That means that each and every time a function i

Data structure layers, Data structure layers: There are many layers in...

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

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd