The matrix array matlab

When doing image processing today, we see a matrix process, a brief talk about the code in the following paragraphs:

First introduced matrix (Note: No in matlab an array or matrix is stored by columns)
First, some create special matrix
zeros (m, n)% 0 establish a full matrix
ones (m, n)% establish a full 1 matrix
eye (m, n)% establish a diagonal matrix of full
matrix rand (m, n)% ( 0,1) randomly distributed
randn (m, n)% compared to a mean of 0, variance. 1
Magic (m, n-)% cube matrix
for elements of the matrix and establish access, and many of the same array previously described
Referring now to Figure access matrix

 

 

 

 Accessing matrix elements can be single and double-subscript access subscripting 

sub2ind () and ind2sub () function of the access mode conversion proceeds; 
A = [. 1:. 4;. 5:. 8] 
IND1 sub2ind = (size (A), 2,3);% index (2,3) into the single subscript index 
[i, j] = ind2sub ( size (A), 7);

 

 

 

 

An array of related operations
A = [. 1 2. 3;. 4. 5. 6;. 7. 8. 9];
B = [. 9. 8. 7;. 6. 5. 4;. 3 2. 1];
A = A (. 1: 2,:) - take the A array of a few lines of elements (here, and the two lines. 1)
A = A (:,. 1: 2) - take the A array of columns of elements (here, and column 2. 1)
A = A (2:. 4) - take the A the second array of four elements to
a = A (1: end) - the positive sequence elements arranged in
a = A (end: -1: 1) - the elements in reverse order
a = A ([2 4] ) - A second array take the fourth element and
a = A (1,2) - taking the first row and first column array element
C = [AB] - array AB transverse splicing
C = [A; B] - array AB longitudinal splice

The following several operations to be familiar with the contents of the array change
A (A = 1) = 100 ;% of the 1 element in the array A becomes full 100
A (A> 4) = 20 is;% greater than the elements of the array A 4 are becomes 20 is
A (1,1) = 10% of the A array element 1 a row 10 becomes
below several functions determined array type
isnumeric ();% is determined whether the numeric array
isreal ();% determines whether real array
isinteger (); determining whether the integer array%, (MATLAB default storage double type)
ISLOGICAL (); if it is determined that the logic array%
find () function: find and modify elements of array elements, specifically shown below

 

 

 

 

 

 


Original link: https: //blog.csdn.net/CV_YOU/article/details/52892673

Guess you like

Origin www.cnblogs.com/fcfc940503/p/11462881.html