中国高校课件下载中心 》 教学资源 》 大学文库

厦门大学数学科学学院:《高等代数》课程教学资源(应用与实验)MATLAB Ex 1 - Matrices & Arrays

文档信息
资源类别:文库
文档格式:PDF
文档页数:3
文件大小:174.77KB
团购合买:点击进入团购
内容简介
厦门大学数学科学学院:《高等代数》课程教学资源(应用与实验)MATLAB Ex 1 - Matrices & Arrays
刷新页面文档预览

MATLAB Exercise I School of Mathematical Sciences Xiamen University ttp: //gdjpkc. xmu.edu MATLAB Exercise I-Matrices Arrays 1. The distance traveled by a ball falling in the air is given by the equation x=xo+vot+=at2 Use mATlaB to calculate the position of the ball at time t=5s if x,=10m, vo=15m/s,and a=-9.81m/sec 2. Suppose that x=3, v=4. Use matlab to evaluate the following expression 1)log(x+v2)2 4)sin 2x|e 2y X 6) 8)eps Help Select Matlab Help in the toolbar, then select Index and input absolute value, finding the function of absolute value Help select Matlab Help in the toolbar, then select Index and input exponential(#*) finding the exponential function Remark: From above example we know, the name of Matlab function is always the abbreviation of its term 42 4. 1)Try to input a vector d=[ 23, 20, 17, 14, 11, 8, 5, 2 in different ways. Use numel to count he number of elements in d 1234 2)Please input matrix a=2 468 at least in three different methods 36912 1)Compute the size of a Help Select Matlab Help in the toolbar, then select Index and input size, understand the different applications of this function e) Show the value of a(2, 3)? Obtain a subarray b which is composed by the 1 and 3 3)Obtain an new matrix c by exchanging the 2 and 3 rows of a 4)Obtain a vector x which is the last column of a (end 5) Replace the value of a(l, 1)with 0 (10) erve what happer

MATLAB Exercise 1  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu  Ex1­1  MATLAB Exercise 1 ­ Matrices & Arrays 1.  The distance traveled by a ball falling in the air is given by the equation  2  0 0  1 2 x = x + v t + at Use MATLAB to calculate the position of the ball at time t=5s if 0  x =10m ,  0  v =15m /s, and  2 a = -9.81m /sec 2.  Suppose that  x = 3 ,  v = 4 . Use MATLAB to evaluate the following expression:  1) 2 2  log(x + v ) 2) 2  3  ( 2 ) x  x v - - 3) 4 2  3 pv 4) |sin 2 | v x e 5) x - 5 6) 4 x  v - 7) 4 x  v - - 8) eps  9) 3 4 x  v - - Help Select Matlab Help in the toolbar, then select Index and input absolute value, finding  the function of absolute value. Help Select  Matlab  Help  in the toolbar,  then select  Index  and input  exponential(指数) ,  finding the exponential function . Remark:From above example  we know,  the name of Matlab  function  is always  the abbreviation of its term.  3. 4/2  4\2 4.  1) Try to input a vector d = [23, 20, 17, 14, 11, 8, 5, 2] in different ways. Use numel to count  the number of elements in d.  2) Please input matrix  1 2 3 4 2 4 6 8 3 6 9 12 a Ê ˆ Á ˜ = Á ˜ Á ˜ Ë ¯ at least in three different methods.  5.  1) Compute the size of a. Help Select  Matlab  Help  in the toolbar,  then select  Index  and input size,  understand the different applications of this function  2) Show the value of a(2,3)? Obtain a subarray b which is  composed  by the 1 st and 3 rd columns of a.  3) Obtain an new matrix c by exchanging the 2 nd and 3 rd rows of a.  4) Obtain a vector x which is the last column of a. (end ) 5) Replace the value of a(1,1) with 0.  6) Input a ( 10 ) a ( 10 ) = 20  a ( 10 ) and observe what happen.  7) Input

AtLAB Exercise l School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu a(2,;) a(:;2:3) a(2:3) 8)Add a new column to a to form a 3 X5 matrix a35, add a new row to a as its 1" row to form a4×4 matrix a44 9)Input a( 20)=100; a and observe what happen. 10)Input d=a' d and compare the value of a with d I 1)Input e=a(13: 12)*Input help format to study"format Help In command window input help format Display the value of pi in short /long format Display 0.5 in short e /rat format 13)In help windows seach fprintf to study"fprintf Display the value of pi as an integer /expone ntial format at the second new line 14)Input a 3X5 matrix newmatrix, compare the results after the following commands a, s newmatrix a* newmatirx a+ newmatrix a newmatrix a. newmatrix 6.TrytosolveforxintheequationAx=bwhereA=232b=1.compArethe command A\B and A/B, try to explain the result. Help Select Matlab Help in the toolbar, then select Index and input/(or ),distinguish the difference between them(corresponding to Exercise 3.) 7. Set A= round(10*rand (6)). Let us change the 6 column A so as to make the matrix singular(奇异).B=A’;A(:,6)=-sum(B(1:5,:)) 1) Set x=ones(6, 1 )and compute A*x. Explain why do we know a must be singula 2) Set C=round( 10 rand(6 )). Check whether AC=CA, why Help in command window input help round, understand the effect of this function. 8. Set A= magic(8). Compute its sum of elements on each row, column and diagonal respectively. 9. Examine the following statements by MATLAB, and show whether they are trl agic matrix Help in command window input help magic to understand how to construct the m 1) IfA#0 and AC=A, then C=D 2)If A and B are nonsingular(]i), then (A+B)=A+B 3) For any 3 3 matrices A andB,(A+B)=A-+2AB+b- Ex1-2

MATLAB Exercise 1  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu  Ex1­2 a ( 2, : ) a ( :, 3 ) a (:, :) a (:, 2 : 3) a (:) a (2 : 3) 8) Add a new column to a to form a 3×5 matrix a35, add a new row to a as its 1 st row to  form a 4×4 matrix a44.  9) Input a ( 20 ) = 100; a and observe what happen.  10) Input d = a’; d and compare the value of a with d.  11) Input e = a ([1 3]; : ) 12) *Input help format to study “format” Help In command window input help format Display the value of pi in short / long format.  Display 0.5 in short e / rat format  13) *In help windows seach fprintf to study  “fprintf” Display the value of pi as an integer / exponential format / at the second new line 14) Input a 3×5 matrix newmatrix, compare the results after the following commands a .* newmatrix  a * newmatirx  a .+ newmatrix  a + newmatrix  a ^ newmatrix  a .^newmatrix 6.  Try to solve for x in the equation Ax = B where 1 2 1 1 2 3 2 , 1 1 0 1 0 A B Ê ˆ Ê ˆ Á ˜ Á ˜ = = Á ˜ Á ˜ Á ˜ Á ˜ - Ë ¯ Ë ¯ . Compare the command A\B and A/B, try to explain the result. Help Select Matlab Help in the toolbar, then select Index and input / (or \), distinguish the difference between them (corresponding to Exercise 3. ).  7.  Set A =  round (10*rand(6)).  Let  us  change the 6 th column  A so as  to make the matrix  singular (奇异). B = A’; A (:, 6) = ­sum (B (1 : 5, : ) )’ 1) Set x = ones (6,1) and compute A*x. Explain why do we know A must be singular.  2) Set C = round ( 10*rand (6 ) ). Check whether AC=CA, why? Help in command window input help round, understand the effect of this function.  8.  Set A =  magic  (8).  Compute  its sum of elements on each row, column  and diagonal  respectively. Help in command window input help magic to understand how to construct the magic matrix  9.  Examine the following statements by MATLAB, and show whether they are true.  1) If A≠0 and AC = AD, then C = D;  2) If A and B are nonsingular (可逆), then  1 1 1  (A B) A B - - - + = + 3) For any 3×3 matrices A and B,  2 2 2  (A+ B) = A + 2AB + B

MATLAB Exercise I School of mathematical ces Xiamen University ttp: //gdjpkc. xmu.edu 4)A+A' Is a symmetric matrix.(对称) 10. Genetrite some spetial matrices 1)Generate a symmetric matrix(Xf FRF)by using function randn and operators"+, 2) Genetrate a upper matrix with positive diagonal elements by using functions round, rand, diag triu and abs testl =linspace(1, 11, 6) test2=linspace(1, 11, 5) num testl= numen(test1) Ii= find (testl >4) testl( find (test1 =3))=0 test= testl; 1: 2: 11l test(: 2)= Magic= magic (5) Magic diag= diag(Magic, 0) Magic diag= diag(Magic, 1) Magic diag= diag(Magic, -1) help cle help clear clear test testI

MATLAB Exercise 1  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu  Ex1­3  4) A+A’ is a symmetric matrix. (对称) 10.  * Genetrite some spetial matrices  1) Generate a symmetric matrix (对称阵) by using function randn and operators ‘ +;  2) Genetrate a upper matrix with positive diagonal elements by using functions round, rand,  diag, triu and abs.  11.  * Some tests test1 = linspace (1, 11, 6) test2 = linspace (1, 11, 5) num_test1 = numel (test1) [ i ] = find (test1 > 4) test1 ( find (test1 ==3)) = 0  test = [test1; 1:2:11] test (:, 2) = [ ] Magic = magic (5) Magic_diag = diag (Magic, 0) Magic_diag = diag (Magic, 1) Magic_diag = diag (Magic, ­1) help clc  clc  help clear clear test test1  clc

已到末页,全文结束
刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档