Matlab学习笔记(3)——Matlab数据结构

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_44568780/article/details/102687650

本节主要是熟悉matlab字符数组的有关内置函数与技巧

字符数组有关操作:

A='Today is Saturday.';
B='I want go home.';
size(A)
size(B)
AB=strcat(A,B)
ab=strvcat(A,B)
size(ab)
double(ab)




>> XXBJ3_19
ans =

     1    18


ans =

     1    15


AB =

Today is Saturday.I want go home.


ab =

Today is Saturday.
I want go home.   


ans =

     2    18


ans =

    84   111   100    97   121    32   105   115    32    83    97   116   117   114   100    97   121    46
    73    32   119    97   110   116    32   103   111    32   104   111   109   101    46    32    32    32

字符串搜索

>> s='Find the starting indices of the shorter string.';
>> k=findstr(s,'the')

k =

     6    30

>> k=findstr(s,'student')

k =

     []

>> k=findstr('the',s)

k =

     6    30

字符串替换

>> S1='The area is at least 400 square meters';
>> newarea=strrep(S1,'400','1000')

newarea =

The area is at least 1000 square meters

ASCII码应用

>> ASCII=char(reshape(32:127,32,3)')

ASCII =

 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~

猜你喜欢

转载自blog.csdn.net/weixin_44568780/article/details/102687650