首页 > 编程语言 > 详细

利用char, str2mat, strvcat创建多行字符串数组

时间:2016-08-30 22:42:11      阅读:132      评论:0      收藏:0      [点我收藏+]

用专门函数char , str2mat , strvcat创建多行字符串数组示例。

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

Convert to character array (string)转换成字符串数组,空字符串是有效的。

示例:
S1=char(‘This string array‘,‘‘, ‘has two rows.‘)  
S1 =
This string array


has two rows.      

2.str2mat  (新版本中被char替代)

Form blank-padded character matrix from strings 

(将字符串转化成有空白填充的字符矩阵)

syntax

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

example

x = str2mat(‘36842‘, ‘39751‘, ‘38453‘, ‘90307‘);

whos x
  Name      Size         Bytes  Class

  x         4x5             40  char array

x(2,3)

ans =

    7

3.strvcat
strvcat会将空字符串忽略掉,这是和char、str2mat的区别。
example:
S3=strvcat(‘123‘, ‘‘, ‘456‘) 
S3 =
123
456

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

利用char, str2mat, strvcat创建多行字符串数组

原文:http://www.cnblogs.com/jiangkejie/p/5823750.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!