1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| A = [1 2 3; 2 3 1; 3 2 4]
B = A'
C = A(:)
D = inv(A)
E = zeros(10, 5, 3) E(:, :, 1) = rand(10, 5) E(:, :, 2) = randi(5, 10, 5) E(:, :, 3) = randn(10, 5)
A = cell(1, 6) A{2} = eye(3) A{5} = magic(5) B = A{5}
books = struct('name', {{'Machine Learning', 'Data Mining'}}, 'price', [30 40]) books.name books.name(1) books.name{1}
A = [1 2 3 4 5 8 5 4 6] B = 1:2:9 C = repmat(B, 3, 1) D = ones(2, 4)
A = [1 2 3 4; 5 6 7 8] B = [1 1 2 2; 2 2 1 1] C = A + B D = A - B E = A * B' F = A .* B G = A / B; H = A ./ B
A = magic(5) B = A(2, 3) C = A(3, :) D = A(:, 4) [m, n] = find (A > 20)
sum = 0;
for n = 1:5 sum = sum + n ^ 2; end
s = 0; n = 1;
while n <= 10 s = s + n; n = n + 1; end
a = 100; b = 20;
if a > b '成立' else '不成立' end
x = 0:0.01:2 * pi; y = sin(x); figure plot(x, y) title('y=sin(x)') xlabel('x') ylabel('sin(x)') xlim([0 2 * pi])
x = 0:0.01:20; y1 = 200 * exp(-0.05 * x) .* sin(x); y2 = 0.8 * exp(-0.5 * x) .* sin(10 * x); figure [AX, H1, H2] = plotyy(x, y1, x, y2, 'plot'); set(get(AX(1), 'Ylabel'), 'String', 'Slow Decay') set(get(AX(2), 'Ylabel'), 'String', 'Fast Decay') xlabel('Time (\musec)') title('Multple Decay Rates') set(H1, 'LineStyle', '--') set(H2, 'LineStyle', ':')
t = 0:pi / 50:10 * pi; plot3(sin(t), cos(t), t) xlabel('sin(t)') ylabel('cos(t)') zlabel('t') grid on axis square
[x, y, z] = peaks(30); mesh(x, y, z) grid
|