display('This is a test') This is a test diary off 'Hello world' ans = Hello world x=[1,2,3] x = 1 2 3 x=[1;2;3] x = 1 2 3 x' ans = 1 2 3 x=[1+i;2;3] x = 1.0000 + 1.0000i 2.0000 + 0.0000i 3.0000 + 0.0000i i^2 ans = -1 x' ans = Columns 1 through 2 1.0000 - 1.0000i 2.0000 + 0.0000i Column 3 3.0000 + 0.0000i x(2) ans = 2 x(3) ans = 3 x(1) ans = 1.0000 + 1.0000i 1:10 ans = Columns 1 through 8 1 2 3 4 5 6 7 8 Columns 9 through 10 9 10 1:2:10 ans = 1 3 5 7 9 x(1:2) ans = 1.0000 + 1.0000i 2.0000 + 0.0000i x([1,3]) ans = 1.0000 + 1.0000i 3.0000 + 0.0000i x*x' ans = Columns 1 through 2 2.0000 + 0.0000i 2.0000 + 2.0000i 2.0000 - 2.0000i 4.0000 + 0.0000i 3.0000 - 3.0000i 6.0000 + 0.0000i Column 3 3.0000 + 3.0000i 6.0000 + 0.0000i 9.0000 + 0.0000i x*x' ans = 2.0000 + 0.0000i 2.0000 + 2.0000i 3.0000 + 3.0000i 2.0000 - 2.0000i 4.0000 + 0.0000i 6.0000 + 0.0000i 3.0000 - 3.0000i 6.0000 + 0.0000i 9.0000 + 0.0000i A=[1,2;3,4] A = 1 2 3 4 A^(-1) ans = -2.0000 1.0000 1.5000 -0.5000 A^(-1)*A ans = 1.0000 0 0.0000 1.0000 A^(-0.5) ans = 0.1031 - 1.2474i 0.1502 + 0.5706i 0.2253 + 0.8559i 0.3284 - 0.3915i A^(-i) ans = 9.6655 +14.4690i -4.4717 - 7.0731i -6.7075 -10.6097i 2.9580 + 3.8593i help power .^ Array power. Z = X.^Y denotes element-by-element powers. X and Y must have the same dimensions unless one is a scalar. A scalar can operate into anything. C = power(A,B) is called for the syntax 'A .^ B' when A or B is an object. See also mpower, nthroot, realpow. Overloaded methods: codistributed/power gpuArray/power Reference page in Help browser doc power doc power A.^(-1) ans = 1.0000 0.5000 0.3333 0.2500 A A = 1 2 3 4 det(A) ans = -2 A=rand(5,5) A = 0.8147 0.0975 0.1576 0.1419 0.6557 0.9058 0.2785 0.9706 0.4218 0.0357 0.1270 0.5469 0.9572 0.9157 0.8491 0.9134 0.9575 0.4854 0.7922 0.9340 0.6324 0.9649 0.8003 0.9595 0.6787 A=randn(5,5) A = 1.0347 0.8884 1.4384 -0.1022 -0.0301 0.7269 -1.1471 0.3252 -0.2414 -0.1649 -0.3034 -1.0689 -0.7549 0.3192 0.6277 0.2939 -0.8095 1.3703 0.3129 1.0933 -0.7873 -2.9443 -1.7115 -0.8649 1.1093 b=randn(5,1) b = -0.8637 0.0774 -1.2141 -1.1135 -0.0068 x=A\b x = -2.0998 -0.5691 1.1474 -1.0105 -2.0245 A*x ans = -0.8637 0.0774 -1.2141 -1.1135 -0.0068 A*x -b ans = 1.0e-15 * 0.1110 0.5690 -0.2220 0.2220 0.5794 A=randn(10,5) A = 1.5326 0.0859 -1.4023 0.6966 0.1873 -0.7697 -1.4916 -1.4224 0.8351 -0.0825 0.3714 -0.7423 0.4882 -0.2437 -1.9330 -0.2256 -1.0616 -0.1774 0.2157 -0.4390 1.1174 2.3505 -0.1961 -1.1658 -1.7947 -1.0891 -0.6156 1.4193 -1.1480 0.8404 0.0326 0.7481 0.2916 0.1049 -0.8880 0.5525 -0.1924 0.1978 0.7223 0.1001 1.1006 0.8886 1.5877 2.5855 -0.5445 1.5442 -0.7648 -0.8045 -0.6669 0.3035 b=randn(10,1) b = -0.6003 0.4900 0.7394 1.7119 -0.1941 -2.1384 -0.8396 1.3546 -1.0722 0.9610 x=A\b x = 0.1968 -0.5451 -0.3891 -0.0027 -0.4322 A*x -b ans = 1.3178 0.7584 0.3845 -0.9195 -0.0121 1.3472 0.7083 -1.2631 0.4151 -0.0566 A=randn(5,10) A = Columns 1 through 7 0.1240 2.9080 -0.2725 -0.3538 0.0335 0.0229 -0.9792 1.4367 0.8252 1.0984 -0.8236 -1.3337 -0.2620 -1.1564 -1.9609 1.3790 -0.2779 -1.5771 1.1275 -1.7502 -0.5336 -0.1977 -1.0582 0.7015 0.5080 0.3502 -0.2857 -2.0026 -1.2078 -0.4686 -2.0518 0.2820 -0.2991 -0.8314 0.9642 Columns 8 through 10 0.5201 -0.1332 -0.2938 -0.0200 -0.7145 -0.8479 -0.0348 1.3514 -1.1201 -0.7982 -0.2248 2.5260 1.0187 -0.5890 1.6555 b=randn(5,1) b = 0.3075 -1.2571 -0.8655 -0.1765 0.7914 x=A\b x = 0.5311 0.4001 0 0 0.6801 0 0.7683 0 0 0.6541 Ax-b {Undefined function or variable 'Ax'. } A*x-b ans = 1.0e-15 * 0.4996 -0.6661 0.3331 0 0.5551 A=randn(5,5) A = -1.3320 0.4517 -1.3617 1.0391 -0.1952 -2.3299 -0.1303 0.4550 -1.1176 -0.2176 -1.4491 0.1837 -0.8487 1.2607 -0.3031 0.3335 -0.4762 -0.3349 0.6601 0.0230 0.3914 0.8620 0.5528 -0.0679 0.0513 A=rand(5,5) A = 0.8176 0.5328 0.6225 0.2305 0.2277 0.7948 0.3507 0.5870 0.8443 0.4357 0.6443 0.9390 0.2077 0.1948 0.3111 0.3786 0.8759 0.3012 0.2259 0.9234 0.8116 0.5502 0.4709 0.1707 0.4302 [V,D]=eig(A) V = Columns 1 through 3 -0.4148 + 0.0000i -0.1182 + 0.0000i 0.4221 - 0.1534i -0.5149 + 0.0000i -0.6330 + 0.0000i -0.3259 + 0.2650i -0.4091 + 0.0000i 0.6586 + 0.0000i 0.0590 + 0.3036i -0.4727 + 0.0000i 0.3843 + 0.0000i -0.5393 + 0.0000i -0.4148 + 0.0000i 0.0623 + 0.0000i 0.1491 - 0.4617i Columns 4 through 5 0.4221 + 0.1534i 0.4618 + 0.0000i -0.3259 - 0.2650i 0.0685 + 0.0000i 0.0590 - 0.3036i -0.8713 + 0.0000i -0.5393 + 0.0000i 0.1456 + 0.0000i 0.1491 + 0.4617i -0.0412 + 0.0000i D = Columns 1 through 3 2.5834 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.6672 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 + 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i Columns 4 through 5 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 - 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.2254 + 0.0000i doc eig help eig eig Eigenvalues and eigenvectors. E = eig(X) is a vector containing the eigenvalues of a square matrix X. [V,D] = eig(X) produces a diagonal matrix D of eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that X*V = V*D. [V,D] = eig(X,'nobalance') performs the computation with balancing disabled, which sometimes gives more accurate results for certain problems with unusual scaling. If X is symmetric, eig(X,'nobalance') is ignored since X is already balanced. E = eig(A,B) is a vector containing the generalized eigenvalues of square matrices A and B. [V,D] = eig(A,B) produces a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A*V = B*V*D. eig(A,B,'chol') is the same as eig(A,B) for symmetric A and symmetric positive definite B. It computes the generalized eigenvalues of A and B using the Cholesky factorization of B. eig(A,B,'qz') ignores the symmetry of A and B and uses the QZ algorithm. In general, the two algorithms return the same result, however using the QZ algorithm may be more stable for certain problems. The flag is ignored when A and B are not symmetric. See also condeig, eigs, ordeig. Overloaded methods: codistributed/eig gpuArray/eig sym/eig Reference page in Help browser doc eig D D = Columns 1 through 3 2.5834 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.6672 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 + 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i Columns 4 through 5 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 - 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.2254 + 0.0000i size(D) ans = 5 5 diag(D) ans = 2.5834 + 0.0000i -0.6672 + 0.0000i 0.1707 + 0.2981i 0.1707 - 0.2981i -0.2254 + 0.0000i V(:,1) ans = -0.4148 -0.5149 -0.4091 -0.4727 -0.4148 A*V(:,1) ans = -1.0715 -1.3302 -1.0568 -1.2211 -1.0717 (A*V(:,1))./V(:,1) ans = 2.5834 2.5834 2.5834 2.5834 2.5834 A*V -V*D ans = 1.0e-15 * Columns 1 through 3 0.4441 + 0.0000i -0.5551 + 0.0000i 0.2776 - 0.0139i -0.4441 + 0.0000i -0.6106 + 0.0000i 0.1110 - 0.1180i 0.0000 + 0.0000i -0.4996 + 0.0000i 0.4996 - 0.2082i 0.0000 + 0.0000i -0.4441 + 0.0000i 0.4302 - 0.2776i 0.0000 + 0.0000i -0.0347 + 0.0000i 0.1110 + 0.1596i Columns 4 through 5 0.2776 + 0.0139i -0.0555 + 0.0000i 0.1110 + 0.1180i 0.3227 + 0.0000i 0.4996 + 0.2082i 0.4718 + 0.0000i 0.4302 + 0.2776i 0.5967 + 0.0000i 0.1110 - 0.1596i -0.2533 + 0.0000i A A = 0.8176 0.5328 0.6225 0.2305 0.2277 0.7948 0.3507 0.5870 0.8443 0.4357 0.6443 0.9390 0.2077 0.1948 0.3111 0.3786 0.8759 0.3012 0.2259 0.9234 0.8116 0.5502 0.4709 0.1707 0.4302 (A+A')/2 ans = 0.8176 0.6638 0.6334 0.3045 0.5196 0.6638 0.3507 0.7630 0.8601 0.4929 0.6334 0.7630 0.2077 0.2480 0.3910 0.3045 0.8601 0.2480 0.2259 0.5470 0.5196 0.4929 0.3910 0.5470 0.4302 [V,D]=eig(A) V = Columns 1 through 3 -0.4148 + 0.0000i -0.1182 + 0.0000i 0.4221 - 0.1534i -0.5149 + 0.0000i -0.6330 + 0.0000i -0.3259 + 0.2650i -0.4091 + 0.0000i 0.6586 + 0.0000i 0.0590 + 0.3036i -0.4727 + 0.0000i 0.3843 + 0.0000i -0.5393 + 0.0000i -0.4148 + 0.0000i 0.0623 + 0.0000i 0.1491 - 0.4617i Columns 4 through 5 0.4221 + 0.1534i 0.4618 + 0.0000i -0.3259 - 0.2650i 0.0685 + 0.0000i 0.0590 - 0.3036i -0.8713 + 0.0000i -0.5393 + 0.0000i 0.1456 + 0.0000i 0.1491 + 0.4617i -0.0412 + 0.0000i D = Columns 1 through 3 2.5834 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.6672 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 + 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i Columns 4 through 5 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1707 - 0.2981i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.2254 + 0.0000i diag(D) ans = 2.5834 + 0.0000i -0.6672 + 0.0000i 0.1707 + 0.2981i 0.1707 - 0.2981i -0.2254 + 0.0000i A=(A+A')/2 A = 0.8176 0.6638 0.6334 0.3045 0.5196 0.6638 0.3507 0.7630 0.8601 0.4929 0.6334 0.7630 0.2077 0.2480 0.3910 0.3045 0.8601 0.2480 0.2259 0.5470 0.5196 0.4929 0.3910 0.5470 0.4302 A A = 0.8176 0.6638 0.6334 0.3045 0.5196 0.6638 0.3507 0.7630 0.8601 0.4929 0.6334 0.7630 0.2077 0.2480 0.3910 0.3045 0.8601 0.2480 0.2259 0.5470 0.5196 0.4929 0.3910 0.5470 0.4302 [V,D]=eig(A) V = 0.0606 -0.4469 0.1852 -0.7078 0.5112 -0.6995 -0.0421 -0.4374 0.2253 0.5166 0.4218 0.6911 -0.3740 -0.2080 0.4017 0.5583 -0.4431 -0.0989 0.5788 0.3837 -0.1319 0.3530 0.7904 0.2645 0.4041 D = -0.7605 0 0 0 0 0 -0.2077 0 0 0 0 0 0.0257 0 0 0 0 0 0.3492 0 0 0 0 0 2.6255 V*V' ans = 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000 -0.0000 -0.0000 0.0000 -0.0000 -0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 1.0000 V*V' -eye(5) ans = 1.0e-15 * 0.2220 -0.0555 -0.7216 -0.3608 -0.1665 -0.0555 -0.2220 -0.1665 -0.0278 0.1943 -0.7216 -0.1665 0.2220 -0.0833 -0.1110 -0.3608 -0.0278 -0.0833 -0.5551 0.0833 -0.1665 0.1943 -0.1110 0.0833 -0.2220 plot(1:10) plot(1:10,'.') plot(1:10,'.) plot(1:10,'.) | {Error: A MATLAB string constant is not terminated properly. } x=1:10; plot(x,1+x.^2) plot(x,1+x.^2,x,x^3) {Error using ^ Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead. } plot(x,1+x.^2,x,x.^3) plot(x,-5x.^2,x,x.^3) plot(x,-5x.^2,x,x.^3) | {Error: Unexpected MATLAB expression. } plot(x,-5+x.^2,x,x.^3) pwd ans = \\nask.man.ac.uk\home$\MATLAB cd .. cd MATLAB pwd ans = \\nask.man.ac.uk\home$\MATLAB exit