tailieunhanh - Engineering and Scientific Computations Using MATLAB phần 4

Ví dụ, chúng ta hãy thay đổi tất cả các yếu tố tiêu cực của các vector hoặc ma trận là tích cực. Để thực hiện điều này, chúng tôi đãKích thước và chiều dài chức năng trả lại kích thước và chiều dài của một vector hoặc ma trận. Ví dụ | Chapter 3 Matlab and Problem Solving 58 because the AA is an active variable. To remove AA from active variables we tvpe clear AA To create other matrices that have the same size as an existing matrix we can use the size operator. For example A-ones 4 D-zeros size A D - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rhe max and min operators return the largest and smallest values in matrices and vectors. For example E magic 4 Maximum-max E Minimum1 min E E - 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 Maximum 16 14 15 13 Minimum 4 2 3 1 16 2 3 13 Ibat is. E 7 14 10 6 15 8 12 . Thus MATLAB has a built-in function that creates the magic squares 9 4 matrices of any size. The sum is the sum of all the elements of the vector or sums the columns for matrices while prod is the product of all the elements of the vector or the product down the columns. That is. S sum E p-prod E s 34 34 34 34 p 2880 2156 2700 1248 A magic square is a square matrix which has equal sums along all its rows and columns. The matrix can be generated using the magic function. For example. a magic 4 a 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 The maximum and minimum entries can be found using the max and min functions. For five rows of the magic matrix a we have a-magic 5 aa max a aaa min a a 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Chapter 3 Matlab and Problem Solving 59 aa 23 aaa 4 24 25 21 22 5 1 2 3 If we do not specify a variable MATLAB uses the variable ans answer to store the results of a calculation. The sums and products of the columns of the magic matrix can be found. We have E-magic 4 ans sum E prod E 34 34 34 34 ans 2880 2156 2700 1248 The user can summate the rows. To do this use the transpose operator. In particular to find the sum of rows we transpose the matrix E. compute the column sums of the transpose and then transpose the result. The transpose operation is denoted by an apostrophe or single quote . It flips a matrix about its main diagonal. The transpose operation turns a row

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.