Illustration of sorting strings, MATLAB in Engineering

Illustration of Sorting strings:

To sort on the rows rather than second dimension should be specified.

>> sort(words,2)

ans =

Hello

Hdowy

Hi

Gbdeooy

Caio

It can be shown by this that the blank space comes before the letters of the alphabet in the character encoding, and that the uppercase letters also come before the lowercase letters.

Now the question is how the strings be sorted alphabetically? The MATLAB has a function sortrows which will do this. The way it works is that it checks the strings column-by-column beginning from the left. If it can establish which letter comes first, it picks up the whole string and puts it in the first row. In this illustration, the first two strings are placed depend on the first character, C and G. For other three strings, they all start with H so the later column is examined. In this situation the strings are placed depend on the second character, e, i, o.

>> sortrows(words)

ans =

Ciao

Goodbye

Hello

Hi

Howdy

Posted Date: 10/22/2012 7:47:28 AM | Location : United States







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

Write discussion on Illustration of sorting strings
Your posts are moderated
Related Questions
Illustration of initializing the data structure: illustration of initializing the data structure by preallocating is here as shown: >> cyls(3) = struct('code', 'c', 'dimen


Example of modular program: In a modular program, there would be one main script which calls three separate functions to complete these tasks: A function to prompt an us

Modular programs: In a modular program, the answer is broken down into modules, and each is executed as a function. The script is usually known as the main program. In orde

Algorithm for expfn function: The algorithm for expfn function is as shown:  receives the value of x as the input argument.  Prints the value of exp(x).  assigns a

Function cirarea - Anonymous functions: The function handle name is cirarea. The one argument is passed to the input argument radius. The body of the function is an expression

Interchange rows : for illustration interchanging rows ri and rj is written as

Appending variables to the Mat-File: Appending to the file adds to what has been saved in a file, and is accomplished by using the -append option. For illustration, supposing

Example of Exponential function modular program: In order to view the distinction in the approximate value for e as n increases, the user kept choosing Limit & entering larger

A matlab function to calculate filter order