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
Defined a variable in work space: The variables defined in the script will become a part of the workspace: >> clear >> who >> mysummfile    15 >> who

Replacing, Finding, and separating strings: There are numerous functions which find and replace the strings, or parts of strings, within the other strings and functions which

Illustration of Sound files: For illustration, the following script generates a subplot which shows the signals from chirp and from train, which is as shown in figure:

Solving 2 × 2 systems of equations: However this may be easy in a MATLAB, in normal finding solutions to the systems of equations is not. The systems which are 2 × 2 are, thou

Function fieldnames - structure functions: The function fieldnames will return the names of the fields which are contained in the structure variable. >> pack_fields = fiel

Finding a sting - function findstr: The function findstr receives two strings as input arguments. It finds all the occurrences of shorter string contained by the longer, and r

Illustration of gauss-jordan: Here's an illustration of performing such substitutions by using MATLAB >> a = [1 3 0; 2 1 3; 4 2 3] a = 1 3 0 2 1 3 4 2

Basic mathematical operations: All the basic mathematical operations can be executed on symbolic expressions and variables (example, add, raise to a power, multiply, subtract,

Help command: The help command is used with the script rectarea, the function readlenwid, and the major function printrectarea. To see the first comment in the subfunction, 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