matlab primer 6th edition phần 3

hoặc nó có thể bị gián đoạn bởi các đối tượng di chuyển đến tiểu bang khác. Một hoạt động được hiển thị bên trong bản thân nhà nước, trước từ "làm" và một dấu gạch năng ILQG là không giống như các Othe bản đồ phân tích cú pháp và phong cách từ chuỗi Chuyển đổi hình ảnh lập chỉ mục cho hình ảnh RGB | The find function The find function is unlike the others. find X where X is a vector returns an array of indices of nonzero entries in X. This is often used in conjunction with relational operators. Suppose you want a vector y that consists of all the values in X greater than 1. Try X 2 rand 1 5 y X find X 1 For matrices i j X@ find A returns three vectors with one entry in i j and X for each nonzero in A row index column index and numerical value respectively . With this matrix A try i j X@ fi nd A .5 i j X@ and you will see a list of pairs of row and column indices where A is greater than .5. However X is a vector of values from the matrix expression A .5 not from the matrix A. Getting the values of A that are larger than .5 without using a loop see Section requires onedimensional array indexing. Try k find A .5 A k . A k A k 99 The loop-based analog of this computation is shown in Section . o 2002 by CRC Press LLC Here s a more complex example. A square matrix A is diagonally dominant if KI X KI for each row i. First enter a matrix that is not diagonally dominant. Try A -1 2 3 -4 0 2 -1 0 1 2 9 i -3 4 1 1@ These statements compute a vector i containing indices of rows that violate diagonal dominance rows 1 and 4 for this matrix A . d diag A a abs d f sum abs A 2 - a i find f a Next modify the diagonal entries to make the matrix just barely diagonally dominant while still preserving the sign of the diagonal m n@ size A k i i-1 -m to 10O Hps s .2 d 15 0 - 1 A k 1 to s . max f i to The variable eps epsilon gives the smallest value such that 1 eps 1 about 10-16 on most computers. It is useful in specifying tolerances for convergence of iterative processes and in problems like this one. The o 2002 by CRC Press LLC odd-looking statement that computes s is nearly the same as s sign d i except that here we want s to be one when d i is zero. We ll come back to this diagonal dominance problem later on. 6. Control Flow Statements In their basic forms these .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.