Experiment 1. Fundamental Knowledge of Matlab (II) 【 Experimental P urposes 】 1 、熟悉并掌握 MATLAB 的工作环境。 2 、运行简单命令,实现数组及矩阵的输入输出,了解在 M ATLAB 下如何绘图。【 Experimental P rinciple 】 1. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated bya space) between brackets, and set it equal toa variable. For example, to create the vector a, enter into the mand window (you can "copy" and "paste" from your browser into MATLAB to make it easy): a= [12345698 7] MATLAB should return: a=123456987 To generate a series that does not use the default of incrementing by 1, specify an additional value with the colon operator (first:step:last). In between the starting and ending value isa step value that tells MATLAB how much to increment (or decrement, if step is negative) between each number it generates. To generate a vector with elements between 0 and 20, incrementing by2 (this method is frequently used to create a time vector) , use t= 0:2:20 t=02468 10 12 14 16 18 20 Manipulating vectors is almost as easy as creating them. First, suppose you would like to add 2 to each of the elements in vector 'a'. The equation for that looks like: b=a+2b=345678 11 109 Now suppose, you would like to add two vectors together. If the two vectors are the same length, it is easy. Simply add the two as shown below: c=a+bc=468 10 12 14 20 18 16 Subtraction of vectors
实验二 MATLAB基础知识(二) 来自淘豆网www.taodocs.com转载请标明出处.