a = 2 a = 2 a = 2; A = [1 2 3 4 5 6; 7,8,9] A = 1 2 3 4 5 6 7 8 9 B = ones(3,5) B = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 B = eye(3,5) B = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 C = ones(3) C = 1 1 1 1 1 1 1 1 1 b = randn(100,1) b = -0.4326 -1.6656 0.1253 0.2877 -1.1465 1.1909 1.1892 -0.0376 0.3273 0.1746 -0.1867 0.7258 -0.5883 2.1832 -0.1364 0.1139 1.0668 0.0593 -0.0956 -0.8323 0.2944 -1.3362 0.7143 1.6236 -0.6918 0.8580 1.2540 -1.5937 -1.4410 0.5711 -0.3999 0.6900 0.8156 0.7119 1.2902 0.6686 1.1908 -1.2025 -0.0198 -0.1567 -1.6041 0.2573 -1.0565 1.4151 -0.8051 0.5287 0.2193 -0.9219 -2.1707 -0.0592 -1.0106 0.6145 0.5077 1.6924 0.5913 -0.6436 0.3803 -1.0091 -0.0195 -0.0482 0.0000 -0.3179 1.0950 -1.8740 0.4282 0.8956 0.7310 0.5779 0.0403 0.6771 0.5689 -0.2556 -0.3775 -0.2959 -1.4751 -0.2340 0.1184 0.3148 1.4435 -0.3510 0.6232 0.7990 0.9409 -0.9921 0.2120 0.2379 -1.0078 -0.7420 1.0823 -0.1315 0.3899 0.0880 -0.6355 -0.5596 0.4437 -0.9499 0.7812 0.5690 -0.8217 -0.2656 c = 10:0.5:20 c = Columns 1 through 4 10.0000 10.5000 11.0000 11.5000 Columns 5 through 8 12.0000 12.5000 13.0000 13.5000 Columns 9 through 12 14.0000 14.5000 15.0000 15.5000 Columns 13 through 16 16.0000 16.5000 17.0000 17.5000 Columns 17 through 20 18.0000 18.5000 19.0000 19.5000 Column 21 20.0000 t = 101:200 t = Columns 1 through 8 101 102 103 104 105 106 107 108 Columns 9 through 16 109 110 111 112 113 114 115 116 Columns 17 through 24 117 118 119 120 121 122 123 124 Columns 25 through 32 125 126 127 128 129 130 131 132 Columns 33 through 40 133 134 135 136 137 138 139 140 Columns 41 through 48 141 142 143 144 145 146 147 148 Columns 49 through 56 149 150 151 152 153 154 155 156 Columns 57 through 64 157 158 159 160 161 162 163 164 Columns 65 through 72 165 166 167 168 169 170 171 172 Columns 73 through 80 173 174 175 176 177 178 179 180 Columns 81 through 88 181 182 183 184 185 186 187 188 Columns 89 through 96 189 190 191 192 193 194 195 196 Columns 97 through 100 197 198 199 200 d = A(2,3) d = 6 e = A([1 2],[1 3]) e = 1 3 4 6 e = A(1: 2,[1 3]) e = 1 3 4 6 f = A(:,2) f = 2 5 8 f = A(1:end,2) f = 2 5 8 g = b(41:end) g = -1.6041 0.2573 -1.0565 1.4151 -0.8051 0.5287 0.2193 -0.9219 -2.1707 -0.0592 -1.0106 0.6145 0.5077 1.6924 0.5913 -0.6436 0.3803 -1.0091 -0.0195 -0.0482 0.0000 -0.3179 1.0950 -1.8740 0.4282 0.8956 0.7310 0.5779 0.0403 0.6771 0.5689 -0.2556 -0.3775 -0.2959 -1.4751 -0.2340 0.1184 0.3148 1.4435 -0.3510 0.6232 0.7990 0.9409 -0.9921 0.2120 0.2379 -1.0078 -0.7420 1.0823 -0.1315 0.3899 0.0880 -0.6355 -0.5596 0.4437 -0.9499 0.7812 0.5690 -0.8217 -0.2656 x = [1 2 3 4 5]; y = x' y = 1 2 3 4 5 y = (1:5)' y = 1 2 3 4 5 D = A + C D = 2 3 4 5 6 7 8 9 10 E = A * B E = 1 2 3 0 0 4 5 6 0 0 7 8 9 0 0 z = y/2 z = 0.5000 1.0000 1.5000 2.0000 2.5000 z = y*0.5 z = 0.5000 1.0000 1.5000 2.0000 2.5000 z = y*(1/2) z = 0.5000 1.0000 1.5000 2.0000 2.5000 F = A^3 F = 468 576 684 1062 1305 1548 1656 2034 2412 H = A.^3 H = 1 8 27 64 125 216 343 512 729 G = A./4 G = 0.2500 0.5000 0.7500 1.0000 1.2500 1.5000 1.7500 2.0000 2.2500 y^2 ??? Error using ==> mpower Matrix must be square. y.^2 ans = 1 4 9 16 25 who Your variables are: A D G ans d g y B E H b e t z C F a c f x size(B) ans = 3 5 [i, j] = size(B) i = 3 j = 5 length(x) ans = 5 y y = 1 2 3 4 5 x x = 1 2 3 4 5 z z = 0.5000 1.0000 1.5000 2.0000 2.5000 format bank z z = 0.50 1.00 1.50 2.00 2.50 help format FORMAT Set output format. FORMAT with no inputs sets the output format to the default appropriate for the class of the variable. For float variables, the default is FORMAT SHORT. FORMAT does not affect how MATLAB computations are done. Computations on float variables, namely single or double, are done in appropriate floating point precision, no matter how those variables are displayed. Computations on integer variables are done natively in integer. Integer variables are always displayed to the appropriate number of digits for the class, for example, 3 digits to display the INT8 range -128:127. FORMAT SHORT and LONG do not affect the display of integer variables. FORMAT may be used to switch between different output display formats of all float variables as follows: FORMAT SHORT Scaled fixed point format with 5 digits. FORMAT LONG Scaled fixed point format with 15 digits for double and 7 digits for single. FORMAT SHORT E Floating point format with 5 digits. FORMAT LONG E Floating point format with 15 digits for double and 7 digits for single. FORMAT SHORT G Best of fixed or floating point format with 5 digits. FORMAT LONG G Best of fixed or floating point format with 15 digits for double and 7 digits for single. FORMAT SHORT ENG Engineering format that has at least 5 digits and a power that is a multiple of three FORMAT LONG ENG Engineering format that has exactly 16 significant digits and a power that is a multiple of three. FORMAT may be used to switch between different output display formats of all numeric variables as follows: FORMAT HEX Hexadecimal format. FORMAT + The symbols +, - and blank are printed for positive, negative and zero elements. Imaginary parts are ignored. FORMAT BANK Fixed format for dollars and cents. FORMAT RAT Approximation by ratio of small integers. Numbers with a large numerator or large denominator are replaced by *. FORMAT may be used to affect the spacing in the display of all variables as follows: FORMAT COMPACT Suppresses extra line-feeds. FORMAT LOOSE Puts the extra line-feeds back in. Example: format short, pi, single(pi) displays both double and single pi with 5 digits as 3.1416 while format long, pi, single(pi) displays pi as 3.14159265358979 and single(pi) as 3.1415927. format, intmax('uint64'), realmax shows these values as 18446744073709551615 and 1.7977e+308 while format hex, intmax('uint64'), realmax shows them as ffffffffffffffff and 7fefffffffffffff respectively. The HEX display corresponds to the internal representation of the value and is not the same as the hexadecimal notation in the C programming language. See also disp, display, isnumeric, isfloat, isinteger. Reference page in Help browser doc format figure plot(b) plot(t,b) w = randn(100,1); plot(t,b,t,w) plot(t,[b w]) diary off