MATLAB Lecture hoolofMathematicalSciencesXiamenUniversityhttp://gdjpkc.xmu.edu.cn 0.0314 > volume area*o. 5% the volume of a cylinder with radius 0.1 and vo⊥ume= 0.0157 >>(12+2*(7-4))/3^2 ans >>8=1-1/2+1/3-1/4+1/5-1/6 +1/7-1/8 0.6345 >>z1=3+4⊥ z1= 3.0000+4.00001 >z2=1+2*⊥ >>z3=2+exp(i*pi/6) >z=z1*z2/z3 MATLAB - Getting Started Matrices and Arrays - Expressions -Operators ● Enter matrices in matlaB(矩阵) P Enter an explicit list of elements Y Separate the elements of a row with blanks or commas 2 Use a semicolon :i to indicate the end of each row Y Surround the entire list of elements with square brackets,[ 1 Load matrices from external data files Generate matrices using built-in functions P Create matrices with your own functions in M-files Array: a collection of data values organized into rows and columns Vector: an array with only one dimension Matrix: an array with two or more dimensions Size: specified by the number of rows and the number of columns in the arra ith the number of rows mentioned first >>[1234 567891: create an arrays with 9 elements >>[1,2,3;4,5,6;7,8,9]% a3×3 matrIx 6 >>[123 456 789MATLAB Lecture 1 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec12 0.0314 >> volume = area*0.5 % the volume of a cylinder with radius 0.1 and … length 0.5 volume = 0.0157 >> (12+2*(74))/3^2 ans = 2 >> S = 1 – 1/2 + 1/3 –1/4 + 1/5 – 1/6 ... + 1/7 – 1/8 S = 0.6345 >> z1 = 3 + 4i z1 = 3.0000 + 4.0000i >> z2 = 1 + 2 * i >> z3 = 2*exp(i*pi/6) >> z = z1*z2/z3 MATLAB → Getting Started → Matrices and Arrays → Expressions → Operators l Enter matrices in MATLAB (矩阵) ÿ Enter an explicit list of elements. You only have to follow a few basic conventions: ² Separate the elements of a row with blanks or commas. ² Use a semicolon ‘;‘ to indicate the end of each row. ² Surround the entire list of elements with square brackets, [ ]. ÿ Load matrices from external data files. ÿ Generate matrices using builtin functions. ÿ Create matrices with your own functions in Mfiles. Array: a collection of data values organized into rows and columns Vector: an array with only one dimension Matrix: an array with two or more dimensions Size: specified by the number of rows and the number of columns in the array, with the number of rows mentioned first. >> [1 2 3 4 5 6 7 8 9]; % create an arrays with 9 elements >> [1,2,3;4,5,6;7,8,9] % create a 3×3 matrix ans = 1 2 3 4 5 6 7 8 9 >> [1 2 3 4 5 6 7 8 9]