• 掌握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=' 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.';
    k=findstr(Str,' ');
    l=length(k);
    for j=1:l
    if(Str(k(j)+1)>='a'&Str(k(j)+1)<='z')
    Str(k(j)+1)=Str(k(j)+1)-'a'+'A';
    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.
    

    (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.';
    >> k=find(Str>='0'&Str<='9');
    >> m=find(Str>='a'&Str<='z');
    >> length(k)
    ans =
    >> length(m)
    ans =
    

    (3)将字符串中间的空格和数字删除,所有字母倒过来重新排序。

    >> 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.';
    S=strrep(Str,' ','')
    k=find(S>='0'&S<='9');
    S(k)='';
    revch=S(end:-1:1)
    1Theexistingresearchisaboutlocationtrackingeithercompletelyindoororaltogetheronopenair2byutilizingvarioussensorsandproceduresbasedoninter-networkingorinternetofthings.
    revch =
    .sgnihtfotenretnirognikrowten-retninodesabserudecorpdnasrosnessuoiravgnizilituybrianeponorehtegotlaroroodniyletelpmocrehtiegnikcartnoitacoltuobasihcraesergnitsixeehT