跳到正文
Hub Nexus
更新

作者暂无作者认领

发现可以改进的地方?提出一个改动吧。

赞助

此页面是公开的。

Special Matrices

Matrix of ones

We can create matrix consists using the functions ones with m numbers of rows and n numbers of columns

>> ones(3,3)

ans =
1 1 1
1 1 1
1 1 1

Matrix of zeroes

We can create matrix consists using the functions zeros with m numbers of rows and n numbers of columns

>> zeros(3,3)

ans =
0 0 0
0 0 0
0 0 0

Identity Matrices

An identity matrix is a square matrix in which each of the elements of its diagonal is a 1 and each of the other elements is a 0.
An identity matrix is used for following purposes:

(a) To verify whether any two given matrices are inverses of each other.

A and B in examples below are inverse to one another

>> A=[3,-2;-1,1]
A =
3 -2
-1 1

>> B=[1,2;1,3]
B =
1 2
1 3

>> A*B
ans =
1 0
0 1

(b) To find the inverse of a matrix

Note 1: Not every inverse matrix can use have identity matrix

Note 2: Command "eye(n)" can be used to create identity matrix in a flash, n is the size of matrix

>> A=[3,2;4,3]
A =
3 2
4 3

>> eye(2)
ans =
1 0
0 1

>> eye(2)/A
ans =
3 -2
-4 3

(c) To find the eigenvalues and eigenvectors.

Eigenvalue is defined as a scalar associated with a given linear transformation of a vector space and having the property that there is some non-zero vector which when multiplied by the scalar is equal to the vector obtained by letting the transformation operate on the vector.

Let say we have a matrix A as followed:

𝐀 = [ \begin{matrix}1 & 4 \\ 3 & 2\end{matrix} ] .

To find lambda, we need to know the equation for finding eigenvalue with following formula :

| A − λ I | = 0

But MATLAB provided a simple way to find eigenvalue using command "eig"

>> A=[1,4;3,2]
A =
1 4
3 2

>> lambda = eig(A)
lambda =
-2
5

Magic Square Matrices

A magic square is basically where the sum of the elements in each column and the sum of the elements in each row are the same and there are no repeating numbers.
We can create a magic square use this command M=magic(n). The order n must be a scalar greater than or equal to 3 in order to create a valid magic square.

For more info, can refer to this well written Wikibooks on this topic: Puzzles/Luoshu Squares

For example , we can create a magic square with matrices 5 by 5

>> % creating 5X5 matrix magic square
>> c = magic(5)
c =
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

Where this page came from

This page was imported from Wikibooks. From “MATLAB Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

收录于这些专栏MATLAB Programming

语言English

许可协议: CC BY-SA 4.0 · 改编自 en.wikibooks.org

观看次数

留言

Spinner Logo
版本: 2CC0 1.0(公有领域)
The runaway star that left the Tarantula Nebula
版本: 2CC0 1.0(公有领域)
The Eagle Nebula, seen in the infrared
版本: 2CC0 1.0(公有领域)
The Cosmic Cliffs are not cliffs
版本: 2CC0 1.0(公有领域)
The recommended targets are real, but the largest health gain is between doing nothing and doing a little. That is the part worth knowing if you are starting from nothing.
版本: 2CC0 1.0(公有领域)
Sleep is not one state but a cycle through several, each doing different work. Most sleep disorders are a failure to complete that cycle rather than a shortage of hours.
版本: 2CC0 1.0(公有领域)
Four nebulae that revealed the shape of our galaxy