Vai al contenuto
Hub Nexus
Aggiornato

AutoreAncora senza autorePrendila in carico

Vedi qualcosa da migliorare? Proponi una modifica.

Sostegno

Questa pagina è pubblica.

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.

In queste pubblicazioniMATLAB Programming

LingueEnglish

Licenza: CC BY-SA 4.0 · Tratto da en.wikibooks.org

Visualizzazioni

Commenti

Spinner Logo
Versione: 2CC0 1.0 (pubblico dominio)
The runaway star that left the Tarantula Nebula
Versione: 2CC0 1.0 (pubblico dominio)
The Eagle Nebula, seen in the infrared
Versione: 2CC0 1.0 (pubblico dominio)
The Cosmic Cliffs are not cliffs
Versione: 2CC0 1.0 (pubblico dominio)
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.
Versione: 2CC0 1.0 (pubblico dominio)
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.
Versione: 2CC0 1.0 (pubblico dominio)
Four nebulae that revealed the shape of our galaxy