Contents
- Vektoren I (Wdh)
- Vektoren II: Transponieren (Wdh)
- Vektoren III: Automatische Erzeugung (Wdh)
- Vektoren IV: Einfache Funktionen (Wdh)
- Vektoren V: Zugriff auf Eintraege
- Rechnen mit Vektoren VI
- Vektoren VII: Lineare Algebra VII
- Rechnen mit Vektoren VIII
- Vektoren IX: Funktionen
- Vergleichen von Vektoren; Suchen von Elementen in Vektoren
- Logische Operationen
- Matrizen I: Erzeugung
- Matrizen II: Spezielle Matrizen
- Matrizen III: Zugriff auf Matrizen
- Matrizen IV: Funktionen fuer Matrixdatentyp
- Matrizen V: Elementweise Operationen
- Matrizen VI: Lineare Algebra
Vektoren I (Wdh)
- Zeilenvektoren: Trennungszeichen ","
- Spaltenvektoren: Trennungszeichen ";"
clc z = [23, 11, 7, 9] s = [23; 11; 7; 9] whos
z =
23 11 7 9
s =
23
11
7
9
Name Size Bytes Class Attributes
s 4x1 32 double
z 1x4 32 double
Vektoren II: Transponieren (Wdh)
- Transponieren und konjugieren mit "'"
- Transponieren ohne konjugieren mit ".'"
v = [1+sqrt(-1), 3-2*sqrt(-1)] v' v.' v''
v = 1.0000 + 1.0000i 3.0000 - 2.0000i ans = 1.0000 - 1.0000i 3.0000 + 2.0000i ans = 1.0000 + 1.0000i 3.0000 - 2.0000i ans = 1.0000 + 1.0000i 3.0000 - 2.0000i
Vektoren III: Automatische Erzeugung (Wdh)
- Erzeugung von Zahlenfolgen "anfang:inkrement:ende"
- linspace(A,B,N): Aequidistante Zerteilung des Intervalls [A,B] in N Punkten
u = 1:10 w = 1:2:10 W = 10:-2:1 t = linspace(0,1,7) dt = 1/6; tt = 0:dt:1 t - tt
u =
1 2 3 4 5 6 7 8 9 10
w =
1 3 5 7 9
W =
10 8 6 4 2
t =
0 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000
tt =
0 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000
ans =
1.0e-15 *
0 0 0 0 -0.1110 0 0
Vektoren IV: Einfache Funktionen (Wdh)
- length(x): Laenge des Vektors x
- size(x): Dimensionen des Vektors x (Ergebnis ist wieder ein Vektor mit Eintraegen Anzahl Zeilen von x und Anzahl Spalten von x)
clc length(z) length(s) size(z) size(ans) whos who
ans =
4
ans =
4
ans =
1 4
ans =
1 2
Name Size Bytes Class Attributes
W 1x5 40 double
ans 1x2 16 double
dt 1x1 8 double
s 4x1 32 double
t 1x7 56 double
tt 1x7 56 double
u 1x10 80 double
v 1x2 32 double complex
w 1x5 40 double
z 1x4 32 double
Your variables are:
W ans dt s t tt u v w z
Vektoren V: Zugriff auf Eintraege
g = w(3) + W(2) w(3) W(2) t(end) t(end-1) w(2:end-1) w([1 4 5]) clc a=1:4 b=linspace(3,6,4)
g =
13
ans =
5
ans =
8
ans =
1
ans =
0.8333
ans =
3 5 7
ans =
1 7 9
a =
1 2 3 4
b =
3 4 5 6
Rechnen mit Vektoren VI
Elementweise Operationen .*, ./, .^
a.*b a./b a.\b a.^3 a.^b
ans =
3 8 15 24
ans =
0.3333 0.5000 0.6000 0.6667
ans =
3.0000 2.0000 1.6667 1.5000
ans =
1 8 27 64
ans =
1 16 243 4096
Vektoren VII: Lineare Algebra VII
Vektoren koennen nur addiert werden, wenn sie die gleiche Laenge haben Skalarmultiplikation *
c = linspace(4,11,6)
%a+c
a + b
alpha = 1i
alpha*c
c =
4.0000 5.4000 6.8000 8.2000 9.6000 11.0000
ans =
4 6 8 10
alpha =
0 + 1.0000i
ans =
Columns 1 through 4
0 + 4.0000i 0 + 5.4000i 0 + 6.8000i 0 + 8.2000i
Columns 5 through 6
0 + 9.6000i 0 +11.0000i
Rechnen mit Vektoren VIII
clc
x = 2:5, y = 4:7
x.^2-x.*x
norm(x)
sqrt(sum(x.^2))
norm(x,inf)
max(x)
z=x+3i*y
(y+j).^2 %was ist das?
x =
2 3 4 5
y =
4 5 6 7
ans =
0 0 0 0
ans =
7.3485
ans =
7.3485
ans =
5
ans =
5
z =
2.0000 +12.0000i 3.0000 +15.0000i 4.0000 +18.0000i 5.0000 +21.0000i
ans =
15.0000 + 8.0000i 24.0000 +10.0000i 35.0000 +12.0000i 48.0000 +14.0000i
Vektoren IX: Funktionen
Norm eines Vektors Groesster und kleinster Eintrag eines Vektors
norm(a) help norm max(a,inf) norm(a,inf) max(a) help help find
ans =
5.4772
NORM Matrix or vector norm.
NORM(X,2) returns the 2-norm of X.
NORM(X) is the same as NORM(X,2).
NORM(X,1) returns the 1-norm of X.
NORM(X,Inf) returns the infinity norm of X.
NORM(X,'fro') returns the Frobenius norm of X.
In addition, for vectors...
NORM(V,P) returns the p-norm of V defined as SUM(ABS(V).^P)^(1/P).
NORM(V,Inf) returns the largest element of ABS(V).
NORM(V,-Inf) returns the smallest element of ABS(V).
By convention, NaN is returned if X or V contains NaNs.
See also COND, RCOND, CONDEST, NORMEST, HYPOT.
Reference page in Help browser
doc norm
ans =
Inf Inf Inf Inf
ans =
4
ans =
4
HELP topics:
matlab/demos - Examples and demonstrations.
toolbox/local - General preferences and configuration information.
matlab/general - General purpose commands.
matlab/ops - Operators and special characters.
matlab/lang - Programming language constructs.
matlab/elmat - Elementary matrices and matrix manipulation.
matlab/randfun - Random matrices and random streams.
matlab/elfun - Elementary math functions.
matlab/specfun - Specialized math functions.
matlab/matfun - Matrix functions - numerical linear algebra.
matlab/datafun - Data analysis and Fourier transforms.
matlab/polyfun - Interpolation and polynomials.
matlab/funfun - Function functions and ODE solvers.
matlab/sparfun - Sparse matrices.
matlab/strfun - Character strings.
matlab/iofun - File input and output.
matlab/timefun - Time and dates.
matlab/datatypes - Data types and structures.
matlab/verctrl - Version control.
matlab/codetools - Commands for creating and debugging code
matlab/helptools - Help commands.
matlab/hds - (No table of contents file)
matlab/guide - Graphical user interface design environment
matlab/datamanager - (No table of contents file)
matlab/graph2d - Two dimensional graphs.
matlab/graph3d - Three dimensional graphs.
matlab/graphics - Handle Graphics.
matlab/plottools - Graphical plot editing tools
matlab/scribe - Annotation and Plot Editing.
matlab/specgraph - Specialized graphs.
matlab/uitools - Graphical user interface components and tools
matlab/optimfun - Optimization and root finding.
signal/sigdemos - (No table of contents file)
matlab/imagesci - Image and scientific data input/output.
matlab/timeseries - Time series data visualization and exploration.
shared/instrument - (No table of contents file)
controllib/graphics - Control Library - Graphics.
graphics/utils - (No table of contents file)
graphics/plotoptions - (No table of contents file)
matlab/audiovideo - Audio and Video support.
shared/siglib - (No table of contents file)
controllib/general - Control System Toolbox - General Utilities.
signal/signal - Signal Processing Toolbox
signal/sigtools - (No table of contents file)
signal/sptoolgui - (No table of contents file)
shared/comparisons - (No table of contents file)
shared/filterdesignlib - (No table of contents file)
shared/imageslib - Image Processing Toolbox Library
images/colorspaces - Image Processing Toolbox --- colorspaces
images/images - Image Processing Toolbox
images/imuitools - Image Processing Toolbox --- imuitools
images/iptformats - Image Processing Toolbox --- File Formats
images/iptutils - Image Processing Toolbox --- utilities
shared/dastudio - (No table of contents file)
images/imdemos - Image Processing Toolbox --- demos and sample images
shared/spcuilib - (No table of contents file)
shared/rptgen - (No table of contents file)
FIND Find indices of nonzero elements.
I = FIND(X) returns the linear indices corresponding to
the nonzero entries of the array X. X may be a logical expression.
Use IND2SUB(SIZE(X),I) to calculate multiple subscripts from
the linear indices I.
I = FIND(X,K) returns at most the first K indices corresponding to
the nonzero entries of the array X. K must be a positive integer,
but can be of any numeric type.
I = FIND(X,K,'first') is the same as I = FIND(X,K).
I = FIND(X,K,'last') returns at most the last K indices corresponding
to the nonzero entries of the array X.
[I,J] = FIND(X,...) returns the row and column indices instead of
linear indices into X. This syntax is especially useful when working
with sparse matrices. If X is an N-dimensional array where N > 2, then
J is a linear index over the N-1 trailing dimensions of X.
[I,J,V] = FIND(X,...) also returns a vector V containing the values
that correspond to the row and column indices I and J.
Example:
A = magic(3)
find(A > 5)
finds the linear indices of the 4 entries of the matrix A that are
greater than 5.
[rows,cols,vals] = find(speye(5))
finds the row and column indices and nonzero values of the 5-by-5
sparse identity matrix.
See also SPARSE, IND2SUB, RELOP, NONZEROS.
Reference page in Help browser
doc find
Vergleichen von Vektoren; Suchen von Elementen in Vektoren
find
clc v<3 v~=3 w =3:9 index = find(w<=5) w(index) = -2*w(index)
ans =
1 0
ans =
1 1
w =
3 4 5 6 7 8 9
index =
1 2 3
w =
-6 -8 -10 6 7 8 9
Logische Operationen
Variablentyp: Wahrheitswert true(=1) oder false(=0) Logisches und && Logisches oder Vergleiche liefern Wahrheitswert 1 oder 0
clc f = false t = true f || t f && t a > c a > b a b find(a > b)
f =
0
t =
1
ans =
1
ans =
0
Error using > Matrix dimensions must agree. Error in vektorenundmatrizen (line 133) a > c
Matrizen I: Erzeugung
Wie Vektoren koennen Matrizen elementweise angegeben werden Separator fuer Zeileneintraege , Separator fuer Spalenumbruch ;
clc z = [1 , 2] v = [1 ; 2] A = [1 , 2 ; 3 , 4] who whos
Matrizen II: Spezielle Matrizen
Nullmatrix, Einheitsmatrix, Matrix mit zufaelligen Eintraegen
N = zeros(2,2) E = eye(2,2) Y = eye(4,2) E = diag([1 1 3 1]) H = diag([1 1 3 1],2) B = rand(2)
Matrizen III: Zugriff auf Matrizen
Zugriff wie bei Vektoren A(Zeilenindex,Spaltenindex)
E(1,1) = 2
Matrizen IV: Funktionen fuer Matrixdatentyp
Groesse der Matrix Anzahl Elemente Anzahl der Nicht-Nullen
size(E) whos numel(E) nnz(E)
Matrizen V: Elementweise Operationen
Wie bei Vektoren .* , ./ , .^
A.*B A./B A.^B
Matrizen VI: Lineare Algebra
Matrizenaddition + Matrix-Vektor Multiplikation * (Dimensionen beachten!) Matrix-Matrix Multiplikation * (Dimensionen beachten!)
A+B A x = [1;2] A*x B A*B F = rand(3,2) G = ones(2,7) F*G G*F