MATLAB string processing functions

Source: Internet
Author: User
Tags strtok

% String processing
A = 'a'; B = 'B'; C = 'cccccc'; M =''
% Get String Length
Length()
% Connects two strings. the rightmost space of each string is trimmed.
D =Strcat(A, c)
Length (d)
% Connects multiple lines of strings. The length of each line can be different. the rightmost side of the non-longest string is automatically filled with spaces.
% Equal to the longest string, the Null String is ignored
E =Strvcat(A, B, m)
Size (E)
% Char connection, empty strings will be filled with spaces
F =Char(A, B, m)
Size (f)

%StrcmpChecks whether two strings are completely equal. Yes, returns true. Otherwise, returns false.
%StrncmpChecks whether the first n characters of two strings are equal. If yes, true is returned. Otherwise, false is returned.
%StrcmpiChecks whether the two strings are completely equal. case-insensitive characters are ignored.
%StrncmpiChecks whether the first n characters of two strings are equal. case insensitive.

%IsletterIndicates whether each character in a string belongs to an English letter.
%IsspaceChecks whether each character in a string belongs to a format character (space, carriage return, tabulation, line break, etc)
%IsstrpropChecks whether each character belongs to a specified range.
A = 'd sdsd 15 #';
B = isletter ()
C = isspace ()

% String replacement and search
%StrrepString replacement, case sensitive
% Strrep (str1, str2, str3)
% It replaces all str2 strings in str1 with str3

%Strfind(STR, Patten) Check if 'str' contains 'pattern' and return the location where it appears. No empty array is returned.
%Findstr(Str1, str2) in str1 and str2, the position where the shorter string appears in the longer string. No empty array is returned.
%Strmatch(Patten, STR) Check whether Patten is consistent with the leftmost part of Str.
%Strtok(STR, char) returns the part before and after the string specified by char in Str,
Mm = 'youqwelcome ';
[MM1, mm2] = strtok (mm, 'q ')

% Blanks (n) Create a string consisting of n Spaces
% Deblank (STR) trim the trailing space of the string
% Strtrim (STR) trim the spaces at the beginning and end of the string, tabulation, and carriage return.

% Lower (STR) converts letters in the string to lowercase letters.
% Upper (STR) converts the letters in the string to uppercase.
% Sort (STR) sorts strings according to their ASCII values.

% Num2str convert a number to a numeric string
% Str2num convert a numeric string to a number
% Mat2str convert the array to a string
% Int2str converts a numeric array to a character array composed of integer numbers

------------------------------

String comparison in cell array:

C = cell (2, 1 );
C (1, 1) = cellstr ('xxx ');
C (2, 1) = cellstr ('yyyyy ');
Strcmp (c {1, 1}, c {2, 1 });

------------------------------

Isequal test Arrays for equality, which can be used to compare whether the two character arrays are the same.

reprinted address: http://www.cnblogs.com/emanlee/archive/2012/09/13/2683912.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.