matlab学习笔记第四章——统计和MATLAB编程介绍

  1.柱状图:

      >> x = [55,63,69,70,75,78,82,84,85,88,90,96,100];

      >> y = [1,2,1,6,4,7,2,1,3,2,4,2,1];
      >> bar(x,y)

  2.我们可以使用barh命令产生水平的柱状图。

  3.通过调用mean函数,MATLAB会告诉我们一组数据的均值是多少。我们也可以传递数组给mean,MATLAB会告诉我们每一列的均值。

  4.x和y数组的向量乘积。我们用s来代表这个中间和:>> s = sum(x.*y)

  5.使用for循环编程:

      for index = start : increment : finish

        statements
      end

  如果我们把增量参数省略,MATLAB就认为我们把增量设为1。

  6.while语句:

      while condition

        statements
      end

  7.switch语句:

      switch expression

        case 1
          do these statements
        case 2
          do these statements
        case n
          do these statements
      end

posted @ 2015-06-18 22:00  xiaobing小兵  阅读(163)  评论(0编辑  收藏  举报