文档详情

Matlab实训3_字符串元胞和结构数组.ppt

发布:2017-05-01约8.98千字共35页下载文档
文本预览下载声明
实训二 字符串数组、元胞数组和结构数组 2.1 字符串数组 2.2 元胞数组(单元数组) 2.3 结构数组(构架数组) 2.1 字符串数组 2.1.1 字符串构造 2.1.2 数字与字符串的相互转换 2.1.3 字符串函数 2.2 单元数组 2.2.1 单元数组的创建 2.2.2 单元数组处理 2.2.3 获得单元数组的内容 2.3 结构数组 2.3.1 创建结构数组 2.3.2 结构处理 2.3.3 获取结构内容 4.3.4 结构函数 要点 字符串数组的创建 字符串转换和操作函数 单元数组的创建和内容获取 结构数组的创建和内容获取 isfield(circle,color) ans = 1 isfield(circle,width) ans = 0 class(square) ans = struct isstruct(circle) ans = 1 d=pi; isstruct(d) ans = 0 fnames=fieldnames(circle) fnames = radius center linestyle color ‘filled circle2=rmfield(circle,fnames{5}) circle2 = 1x3 struct array with fields: radius center linestyle color circle3=rmfield(circle,radius) circle3 = 1x3 struct array with fields: center linestyle color filled * t=How about this character string? t = How about this character string? size(t) ans = 1 32 whos Name Size Bytes Class t 1x32 64 char array Grand total is 34 elements using 80 bytes u=abs(t) u = Columns 1 through 12 72 111 119 32 97 98 111 117 116 32 116 104 Columns 13 through 24 105 115 32 99 104 97 114 97 99 116 101 114 Columns 25 through 32 32 115 116 114 105 110 103 63 char(u) ans = How about this character string? u=t(16:24) u = character u=‘ Hello, ; v=‘ World! ; v=[ Character strings having more than one row must have the same number of column just like matrices! ] v = Character strings having more than one row must have the same number of column just like matrices! w=[u v] w = Hello,World! disp(w) Hello,World! lengends=char(‘Wilt’,‘Russel’,‘Kareem) lengends = Wilt Russel Kareem char(one,,tow,three) ans = one tow three strvcat(one,,two,three) ans = one two three 字符串转换成大写 upper 字符串转换成数字 str2num 字符串转换成一个文本矩阵 str2mat 用格式控制,字符串转换成数字 sscanf 用格式控制,数字转换成字符串 sprintf ASCII转换成字符串
显示全部
相似文档