Comparing strings, MATLAB in Engineering

Comparing strings:

There are few functions which compare strings and return logical true when they are equivalent or logical false when not. The function strcmp compares the strings, character by character. It returns the logical true if strings are completely similar (it also infers that they should be of similar length) or logical false if the strings are not of similar length or any equivalent characters are not identical. Here are some illustrations of such comparisons:

>> word1 = 'cat';

>> word2 = 'car';

>> word3 = 'cathedral';

>> word4 = 'CAR';

>> strcmp(word1,word2)

ans =

0

>> strcmp(word1,word3)

ans =

0

>> strcmp(word1,word1)

ans =

1

>> strcmp(word2,word4)

ans =

0

Posted Date: 10/20/2012 5:26:13 AM | Location : United States







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

Write discussion on Comparing strings
Your posts are moderated
Related Questions
Use of built-in colormaps: MATLAB has built-in colormaps, it is also possible to generate others by using combinations of any colors. For illustration, the following generates

num2str function: The num2str function, that converts real numbers, can be called in many ways. If only the real number is passed to the num2str function, it will generate a s

deblank function: The deblank function eliminates only trailing blanks from the string, not leading the blanks. The strtrim function will eliminate both the leading and traili

Changing Case: The MATLAB has two functions which convert strings to all uppercase letters, or all lowercase, known as the upper and lower. >> mystring = 'AbCDEfgh';

Example to change the line width from the default: For illustration, to change the line width from the default of 0.5 to 1.5: >> set(hl,'LineWidth',1.5) As long as the

Tracing of Square matrices: The trace of a square matrix is the addition of all the elements on the diagonal. For illustration, for the preceding matrix it is 1 + 6 + 11 + 16,

Finding products by for loop: an illustration, when 5 is passed to be the value of the input argument n, the function will compute and return 1 + 2 + 3 + 4 + 5, or 15: >> s

Algorithm for the function explaine: The algorithm for the function explaine is as shown:  Print a description of e, the exp function, and how to find the approximate va

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

Illustration of initializing the data structure: illustration of initializing the data structure by preallocating is here as shown: >> cyls(3) = struct('code', 'c', 'dimen