深圳建设局官网站,wordpress建博客,北京网站开发招聘58,网络公关公司联系方式一、实验任务和目的
掌握Matlab的字符串常用函数及其操作方法。掌握Matlab的结构体的基本操作方法。掌握Matlab的元胞数组的基本操作方法。 二、实验内容字符串数组Str[‘hopes, dreams, hold up, old up’]#xff0c;查找’O’出现的次数和位置。现有三个字符串变量s1“i”…一、实验任务和目的
掌握Matlab的字符串常用函数及其操作方法。掌握Matlab的结构体的基本操作方法。掌握Matlab的元胞数组的基本操作方法。 二、实验内容字符串数组Str[‘hopes, dreams, hold up, old up’]查找’O’出现的次数和位置。现有三个字符串变量s1“i”s2“love”s3“matlab7.1”利用字符串处理函数将其用空格连接在一起并字母转换为大写并将7.1替换为2016a。Str’ 1 The existing research is about location tracking either completely indoor or altogether on open air 2 by utilizing various sensors and procedures based on inter-networking or internet of things.’对该字符串做如下处理 1判断字符串中每个单词的首字母是否大写若不是则将其修改为大写其他字母为小写。 2统计字符串中的数字和字母的个数。 3将字符串中间的空格和数字删除所有字母倒过来重新排序。创建一个结构体用于统计学生的情况包括学生的姓名、学号、各科成绩等。然后使用该结构体对一个班级的学生的成绩进行管理如计算总分、平均分、排列名次等。创建一个2X2的元胞数组第1、2个元素为字符串第3元素为整型第4元素为双精度类型并将其用图形表示。
三、实验过程和结果
字符串数组Str[‘hopes, dreams, hold up, old up’]查找’O’出现的次数和位置。 Str[hopes, dreams, hold up, old up];
pfindstr(Str,O)p [] length(p)ans 02 . 现有三个字符串变量s1“i”s2“love”s3“matlab7.1”并字母转换为大写并将7.1替换为2016a。 s1i;s2love;s3matlab7.1s4strcat(s1,32,s2,32,s3);kfind(s4as4z);s4(k)s4(k)-aA;s4s4 I LOVE MATLAB7.1 strrep(s4,7.1,2016a)ans I LOVE MATLAB2016a3 . Str’ 1 The existing research is about location tracking either completely indoor or altogether on open air 2 by utilizing various sensors and procedures based on inter-networking or internet of things.’对该字符串做如下处理 1判断字符串中每个单词的首字母是否大写若不是则将其修改为大写其他字母为小写。 Str 1 The existing research is about location tracking either completely indoor or altogether on open air 2 by utilizing various sensors and procedures based on inter-networking or internet of things.;
kfindstr(Str, );
llength(k);
for j1:l
if(Str(k(j)1)aStr(k(j)1)z)
Str(k(j)1)Str(k(j)1)-aA;
end
endStrStr 1 The Existing Research Is About Location Tracking Either Completely Indoor Or Altogether On Open Air 2 By Utilizing Various Sensors And Procedures Based On Inter-networking Or Internet Of Things.2统计字符串中的数字和字母的个数。 Str 1 The existing research is about location tracking either completely indoor or altogether on open air 2 by utilizing various sensors and procedures based on inter-networking or internet of things.;kfind(Str0Str9);mfind(StraStrz);length(k)ans 2 length(m)ans 1623将字符串中间的空格和数字删除所有字母倒过来重新排序。 Str 1 The existing research is about location tracking either completely indoor or altogether on open air 2 by utilizing various sensors and procedures based on inter-networking or internet of things.;
Sstrrep(Str, ,)
kfind(S0S9);
S(k);
revchS(end:-1:1)S 1Theexistingresearchisaboutlocationtrackingeithercompletelyindoororaltogetheronopenair2byutilizingvarioussensorsandproceduresbasedoninter-networkingorinternetofthings.revch .sgnihtfotenretnirognikrowten-retninodesabserudecorpdnasrosnessuoiravgnizilituybrianeponorehtegotlaroroodniyletelpmocrehtiegnikcartnoitacoltuobasihcraesergnitsixeehT4 创建一个结构体用于统计学生的情况包括学生的姓名、学号、各科成绩等。然后使用该结构体对一个班级的学生的成绩进行管理如计算总分、平均分、排列名次等。
这里假设一个班有三名同学不好意思这个我暂时不会
5 创建一个2X2的元胞数组第1、2个元素为字符串第3元素为整型第4元素为双精度类型并将其用图形表示。 Acell(2,2);A(1,1){i love};A(2,1){you};A(1,2){int16(128)};A(2,2){double(16)};cellplot(A)四、实验总结和心得 掌握了字符串的查找连接删除倒置替换等一系列操作 掌握了结构数组和元胞数组的用法