A=[1,2;3,4]; B=[5,6;7,8]; C=A+B C = 6 8 10 12 D=B+A D = 6 8 10 12 E=A-B E = -4 -4 -4 -4 F=-B+A F = -4 -4 -4 -4 G=B-A G = 4 4 4 4 H=-A+B H = 4 4 4 4 format compact A A = 1 2 3 4 B B = 5 6 7 8 K=A.*B K = 5 12 21 32 L=B.*A L = 5 12 21 32 format rat A A = 1 2 3 4 B B = 5 6 7 8 M=A./B M = 1/5 1/3 3/7 1/2 N=B./A N = 5 3 7/3 2 O=A.\B O = 5 3 7/3 2 P=B.\A P = 1/5 1/3 3/7 1/2 A A = 1 2 3 4 A.*A ans = 1 4 9 16 A.^2 ans = 1 4 9 16 A.*A.*A ans = 1 8 27 64 A.^3 ans = 1 8 27 64 a=[1:4] a = Columns 1 through 2 1 2 Columns 3 through 4 3 4 format format compact a=[1:4] a = 1 2 3 4 b=[5:8] b = 5 6 7 8 c=a+b c = 6 8 10 12 d=a.*b d = 5 12 21 32 A A = 1 2 3 4 A.*5 ans = 5 10 15 20 A A = 1 2 3 4 m=[8,9] m = 8 9 A.*m ans = 8 18 24 36 n=[5;6] n = 5 6 A A = 1 2 3 4 A.*n ans = 5 10 18 24 A A = 1 2 3 4 B B = 5 6 7 8 A*B ans = 19 22 43 50 B*A ans = 23 34 31 46 R=[1:3;4:6] R = 1 2 3 4 5 6 Q=[1:4;2:5;3:6] Q = 1 2 3 4 2 3 4 5 3 4 5 6 S=R*Q S = 14 20 26 32 32 47 62 77 Q*R {Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.} A A = 1 2 3 4 B B = 5 6 7 8 format rat A/B ans = 3 -2 2 -1 B/A ans = -1 2 -2 3 A\B ans = -3 -4 4 5 B\A ans = 5 4 -4 -3 A A = 1 2 3 4 inv(A) ans = -2 1 3/2 -1/2 inv(B) ans = -4 3 7/2 -5/2 A/B ans = 3 -2 2 -1 A*inv(B) ans = 3 -2 2 -1 A\B ans = -3 -4 4 5 inv(A*B) ans = 25/2 -11/2 -43/4 19/4 inv(A)*B ans = -3 -4 4 5 B/A ans = -1 2 -2 3 B*inv(A) ans = -1 2 -2 3 B\A ans = 5 4 -4 -3 inv(B)*A ans = 5 4 -4 -3 A*A ans = 7 10 15 22 A^2 ans = 7 10 15 22 A A = 1 2 3 4 A*inv(A) ans = 1 0 * 1 format format compact A*inv(A) ans = 1.0000 0 0.0000 1.0000 B B = 5 6 7 8 inv(B)*B ans = 1.0000 0 -0.0000 1.0000 R R = 1 2 3 4 5 6 R*inv(R) {Error using inv Matrix must be square.} A A = 1 2 3 4 A.' ans = 1 3 2 4 A*A.' ans = 5 11 11 25 B*B.' ans = 61 83 83 113 R R = 1 2 3 4 5 6 R.' ans = 1 4 2 5 3 6 R*R.' ans = 14 32 32 77 R.'*R ans = 17 22 27 22 29 36 27 36 45 ones(2,3) ans = 1 1 1 1 1 1 ones(2,3).*6 ans = 6 6 6 6 6 6 zeros(4,2) ans = 0 0 0 0 0 0 0 0 zeros(5) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ones(3) ans = 1 1 1 1 1 1 1 1 1 eye(4) ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 eye(2,3) ans = 1 0 0 0 1 0 eye(4,3) ans = 1 0 0 0 1 0 0 0 1 0 0 0 A A = 1 2 3 4 A*eye(2) ans = 1 2 3 4 eye(2)*A ans = 1 2 3 4 R R = 1 2 3 4 5 6 R*eye(3) ans = 1 2 3 4 5 6 eye(2)*R ans = 1 2 3 4 5 6 T=magic(5) T = 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 [r,s]=size(T) r = 5 s = 5 T*eye(r) ans = 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 eye(s)* eye(s)*  {Error: Invalid expression. Check for missing or extra characters. } eye(s)*t {Undefined function or variable 't'.} eye(s)*T ans = 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 sum(T) ans = 65 65 65 65 65 a a = 1 2 3 4 sum(a) ans = 10 diag(T) ans = 17 5 13 21 9 sum(diag(T)) ans = 65 T T = 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 T.' ans = 17 23 4 10 11 24 5 6 12 18 1 7 13 19 25 8 14 20 21 2 15 16 22 3 9 sum(T.') ans = 65 65 65 65 65 magic(3) ans = 8 1 6 3 5 7 4 9 2 format rat pascal(4) ans = Columns 1 through 2 1 1 1 2 1 3 1 4 Columns 3 through 4 1 1 3 4 6 10 10 20 format format compact pascal(4) ans = 1 1 1 1 1 2 3 4 1 3 6 10 1 4 10 20 pascal(6) ans = 1 1 1 1 1 1 1 2 3 4 5 6 1 3 6 10 15 21 1 4 10 20 35 56 1 5 15 35 70 126 1 6 21 56 126 252 format rat hilbert(4) ans = 4 rand(3) ans = Columns 1 through 2 664/815 717/785 1298/1433 1493/2361 751/5914 694/7115 Column 3 408/1465 1324/2421 338/353 format format compact rand(3) ans = 0.9649 0.9572 0.1419 0.1576 0.4854 0.4218 0.9706 0.8003 0.9157 randn(3) ans = 1.4090 -1.2075 0.4889 1.4172 0.7172 1.0347 0.6715 1.6302 0.7269 randn(3) ans = -0.3034 0.8884 -0.8095 0.2939 -1.1471 -2.9443 -0.7873 -1.0689 1.4384 grafNahoda grafNahoda grafNahoda grafNahoda grafNahoda help plot plot Linear plot. plot(X,Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, disconnected line objects are created and plotted as discrete points vertically at X. plot(Y) plots the columns of Y versus their index. If Y is complex, plot(Y) is equivalent to plot(real(Y),imag(Y)). In all other uses of plot, the imaginary part is ignored. Various line types, plot symbols and colors may be obtained with plot(X,Y,S) where S is a character string made from one element from any or all the following 3 columns: b blue . point - solid g green o circle : dotted r red x x-mark -. dashdot c cyan + plus -- dashed m magenta * star (none) no line y yellow s square k black d diamond w white v triangle (down) ^ triangle (up) < triangle (left) > triangle (right) p pentagram h hexagram For example, plot(X,Y,'c+:') plots a cyan dotted line with a plus at each data point; plot(X,Y,'bd') plots blue diamond at each data point but does not draw any line. plot(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by the (X,Y,S) triples, where the X's and Y's are vectors or matrices and the S's are strings. For example, plot(X,Y,'y-',X,Y,'go') plots the data twice, with a solid yellow line interpolating green circles at the data points. The plot command, if no color is specified, makes automatic use of the colors specified by the axes ColorOrder property. By default, plot cycles through the colors in the ColorOrder property. For monochrome systems, plot cycles over the axes LineStyleOrder property. Note that RGB colors in the ColorOrder property may differ from similarly-named colors in the (X,Y,S) triples. For example, the second axes ColorOrder property is medium green with RGB [0 .5 0], while plot(X,Y,'g') plots a green line with RGB [0 1 0]. If you do not specify a marker type, plot uses no marker. If you do not specify a line style, plot uses a solid line. plot(AX,...) plots into the axes with handle AX. plot returns a column vector of handles to lineseries objects, one handle per plotted line. The X,Y pairs, or X,Y,S triples, can be followed by parameter/value pairs to specify additional properties of the lines. For example, plot(X,Y,'LineWidth',2,'Color',[.6 0 0]) will create a plot with a dark red line width of 2 points. Example x = -pi:pi/10:pi; y = tan(sin(x)) - sin(tan(x)); plot(x,y,'--rs','LineWidth',2,... 'MarkerEdgeColor','k',... 'MarkerFaceColor','g',... 'MarkerSize',10) See also plottools, semilogx, semilogy, loglog, plotyy, plot3, grid, title, xlabel, ylabel, axis, axes, hold, legend, subplot, scatter. Reference page for plot Other functions named plot grafNahoda grafNahoda grafNahoda graficek graficek