Create multi-line string arrays with char, Str2mat, Strvcat

Source: Internet
Author: User
Tags array example

Create a multi-line string array example with specialized functions char, Str2mat, Strvcat.

1.char (' str1 ', ' str2 ',...)

Convert to character array (string) is converted to a string array, and an empty string is valid.

Example:
S1=char (' This string array ', ' ", ' has both rows. ')
S1 =
This string array


has both rows.

2.str2mat (char replaced in new version)

Form blank-padded character Matrix from strings

(Converts a string into a character matrix with blank padding)

Syntax

S = Str2mat (T1, T2, T3, ...)

Example
x = Str2mat (' 36842 ', ' 39751 ', ' 38453 ', ' 90307 '); whos x  Name      Size         Bytes  Class  x         4x5             40  Char Arrayx (2,3) ans =    7

3.strvcat
Strvcat will ignore the empty string, which is the difference between char and Str2mat.
Example


123
456

Use char, Str2mat, Strvcat to create a multiline string array

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.