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
Subfunctions: Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the prima

Program to Counting in a while loop: The script initializes variable counter to 0. Then, in the while loop action, each and every time the user successfully enter a number, th

A matlab function to calculate filter order

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

Passing arguments to functions: In all these functions examples faraway, at least one of the arguments was passed in the function call to be the value(s) of the equivalent inp

ischar function: The ischar function return the logical true if an array is a character array, or logical false if not. >> vec = 'EK127'; >> ischar(vec) ans =

Function iscellstr - string function: The function iscellstr will return the logical true when a cell array is a cell array of all the strings, or logical false if not. >>

Illustration of Set operations: For illustration, given the vectors as shown below: >> v1 = 2:6 v1 = 2  3  4  5  6 >> v2 = 1:2:7 v2 = 1  3  5  7

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

Illustration of Subfunctions: This is an illustration of running this program: >> rectarea Please enter the length: 6 Please enter the width: 3 For a rectan