cviceni 1 ========= a = 5 b = 6; c = (a+b)*3/(20-a) c sqrt(5-3*i) a=sqrt(2) + sin(c+1); help sin ========= pole - vektory ============= y = [ 2 0 1 -2 -3 4 1]; y(3) y(3) = 7; y' x = -1:4; x = 2 : 0.5 : 5; c = pi : 0.5 : 2*pi; ---- rozdil vektoru y-x --------- size(x) size(y) d = y-x ---- maximalni prvek ve vektoru d (v abs. hodnote) --------- max(abs(d)) ------ funkce vsech prvku vektoru ----- y = x.*exp(x)+x.^2; ========== graf ============== plot(x, y) plot(x,y, 'r') plot(x,y, 'go') plot(x,y, 'r*') help plot % parametricka krivka: t = 0 : 0.2 : 2*pi; x = sin(t); y = cos(t); plot(x, y) axis equal axis normal ==== jednoduche grafy =========== ezplot('x*sin(x)') % na intervalu < -2*pi, 2*pi > nebo: f = 'x*sin(x)'; ezplot(f) grid on ezplot(f, [-2, 10]) % na intervalu < -2, 10 > % nebo ezplot(f, -2, 10) ======= ezplot pro 2 promenne ============ ezplot('x^2 + y^2 - 4') f = 'x^2 - y^2-5'; ezplot(f, [-10, 10]) % ve ctverci ezplot(f, [-10, 10, -5, 5]) % v obdelniku % graficke reseni rovnic ezplot('x^2 + 1') % prvni funkce hold on % kresleni do stejneho obr. ezplot('x^2 + y^2 - 4') % druha funkce axis([-2 2 0 3]) % zvetseni grafu v miste pruseciku ============================================= =========== 2D pole - matice ================ A = [ 1 2 3; 4 5 6]; size(A) % pocet radku, pocet sloupcu A(2,3) % prvek v 2. radku a 3. sloupci A(2,:) % druhy radek A(:,3) % treti sloupec --- scitani matic: B = [ 0 -2 1; 1 0 1]; C = A + B; Z = 0.3 * A --- nasobeni matic: X = A*A' Y = [1 2; -3 2] * A --- reseni soustavy rovnic (se ctvercovou matici): A = [ 3 2 1; 0 2 0; 3 6 7]; b = [ 11; 2; 33]; % nebo b = [ 11 2 33]'; x = A \ b --- funkce cele matice -------- B = A^2 det(A) % determinant inv(A) % inverzni matice % vlastni cisla eig(A) [U, D]=eig(A) % vlastni cisla a vl. vektory % maticove plati A*U - D*U = 0 : A*U - D*U % pro k = 1, 2, 3 : k=1; U(:,k) % vl. vektor D(k,k) % odpovidajici vl. cislo % tedy plati A*U(:,k)-D(k,k)*U(:,k) = 0 pro k = 1,2,3 : k=1; A*U(:,k)-D(k,k)*U(:,k) ------ funkce vsech prvku matice ----- B = A.*A; C = A.^2; S = sin(A); ===============================================================