a = 6
a =
6
b= 34
b =
34
A = [ 1,3,5; 9, 7, -5]
A =
1 3 5
9 7 -5
disp('hello')
hello
cos(67)
ans =
-0.5178
cos(a)
ans =
0.9602
cos(b)
ans =
-0.8486
cos(A)
ans =
0.5403 -0.9900 0.2837
-0.9111 0.7539 0.2837
A
A =
1 3 5
9 7 -5
co(1)
{Undefined function 'co' for input arguments of type
'double'.
}
cos(1)
ans =
0.5403
cos(3)
ans =
-0.9900
cos(5)
ans =
0.2837
cos(A)
ans =
0.5403 -0.9900 0.2837
-0.9111 0.7539 0.2837
1:5
ans =
1 2 3 4 5
% Range
2:4
ans =
2 3 4
2.1:4.1
ans =
2.1000 3.1000 4.1000
2.1:4.2
ans =
2.1000 3.1000 4.1000
2.1:5.0
ans =
2.1000 3.1000 4.1000
2.1:5.1
ans =
2.1000 3.1000 4.1000 5.1000
1:20
ans =
Columns 1 through 9
1 2 3 4 5 6 7 8 9
Columns 10 through 18
10 11 12 13 14 15 16 17 18
Columns 19 through 20
19 20
1:2:20
ans =
Columns 1 through 9
1 3 5 7 9 11 13 15 17
Column 10
19
1:3:20
ans =
1 4 7 10 13 16 19
1:4:20
ans =
1 5 9 13 17
1:4.6:20
ans =
1.0000 5.6000 10.2000 14.8000 19.4000
20:-2:1
ans =
Columns 1 through 9
20 18 16 14 12 10 8 6 4
Column 10
2
20:-2:0
ans =
Columns 1 through 9
20 18 16 14 12 10 8 6 4
Columns 10 through 11
2 0
20:-2:-10
ans =
Columns 1 through 9
20 18 16 14 12 10 8 6 4
Columns 10 through 16
2 0 -2 -4 -6 -8 -10
20:2:-10
ans =
Empty matrix: 1-by-0
c = 20:-2:-10
c =
Columns 1 through 9
20 18 16 14 12 10 8 6 4
Columns 10 through 16
2 0 -2 -4 -6 -8 -10
whos
Name Size Bytes Class Attributes
A 2x3 48 double
a 1x1 8 double
ans 1x0 0 double
b 1x1 8 double
c 1x16 128 double
1:7:90
ans =
Columns 1 through 9
1 8 15 22 29 36 43 50 57
Columns 10 through 13
64 71 78 85
1:12
ans =
Columns 1 through 9
1 2 3 4 5 6 7 8 9
Columns 10 through 12
10 11 12
0:11
ans =
Columns 1 through 9
0 1 2 3 4 5 6 7 8
Columns 10 through 12
9 10 11
1:31
ans =
Columns 1 through 9
1 2 3 4 5 6 7 8 9
Columns 10 through 18
10 11 12 13 14 15 16 17 18
Columns 19 through 27
19 20 21 22 23 24 25 26 27
Columns 28 through 31
28 29 30 31
30:0:31
ans =
Empty matrix: 1-by-0
2016:76:-1
ans =
Empty matrix: 1-by-0
2016:-79:-1
ans =
Columns 1 through 4
2016 1937 1858 1779
Columns 5 through 8
1700 1621 1542 1463
Columns 9 through 12
1384 1305 1226 1147
Columns 13 through 16
1068 989 910 831
Columns 17 through 20
752 673 594 515
Columns 21 through 24
436 357 278 199
Columns 25 through 26
120 41
2016:-30:-44
ans =
Columns 1 through 4
2016 1986 1956 1926
Columns 5 through 8
1896 1866 1836 1806
Columns 9 through 12
1776 1746 1716 1686
Columns 13 through 16
1656 1626 1596 1566
Columns 17 through 20
1536 1506 1476 1446
Columns 21 through 24
1416 1386 1356 1326
Columns 25 through 28
1296 1266 1236 1206
Columns 29 through 32
1176 1146 1116 1086
Columns 33 through 36
1056 1026 996 966
Columns 37 through 40
936 906 876 846
Columns 41 through 44
816 786 756 726
Columns 45 through 48
696 666 636 606
Columns 49 through 52
576 546 516 486
Columns 53 through 56
456 426 396 366
Columns 57 through 60
336 306 276 246
Columns 61 through 64
216 186 156 126
Columns 65 through 68
96 66 36 6
Column 69
-24
gen = 30
gen =
30
ancestors = 2016:-gen:-44;
date
ans =
30-Aug-2016
help date
date Current date as date string.
S = date returns a string containing the date in dd-mmm-yyyy format.
See also now, clock, datenum.
Reference page in Help browser
doc date
docsearch date
time
{Undefined function or variable 'time'.
}
clock
ans =
1.0e+03 *
Columns 1 through 5
2.0160 0.0080 0.0300 0.0160 0.0050
Column 6
0.0278
tic
ancestors = 2016:-gen:-44;
toc
Elapsed time is 5.586288 seconds.
format long
clock
ans =
1.0e+03 *
Columns 1 through 2
2.016000000000000 0.008000000000000
Columns 3 through 4
0.030000000000000 0.016000000000000
Columns 5 through 6
0.008000000000000 0.000021754000000
help toc
toc Read the stopwatch timer.
TIC and toc functions work together to measure elapsed time.
toc, by itself, displays the elapsed time, in seconds, since
the most recent execution of the TIC command.
T = toc; saves the elapsed time in T as a double scalar.
toc(TSTART) measures the time elapsed since the TIC command that
generated TSTART.
Example: Measure the minimum and average time to compute a sum
of Bessel functions.
REPS = 1000; minTime = Inf; nsum = 10;
tic;
for i=1:REPS
tstart = tic;
sum = 0; for j=1:nsum, sum = sum + besselj(j,REPS); end
telapsed = toc(tstart);
minTime = min(telapsed,minTime);
end
averageTime = toc/REPS;
See also tic, cputime.
Reference page in Help browser
doc toc
tic
ancestors = 2016:-gen:-44;
etime = toc
etime =
8.479753622000000
tic
ancestors = 2016:-gen:-44;
etime = toc
etime =
11.357849150000000
A
A =
1 3 5
9 7 -5
A(1:2, 2:3)
ans =
3 5
7 -5
A(1,2)
ans =
3
1 3 5
1 3 5
|
{Error: Unexpected MATLAB expression.
}
A(1, 2:3)
ans =
3 5
A
A =
1 3 5
9 7 -5
A(1:2,2)
ans =
3
7
A(2,:)
ans =
9 7 -5
A(2)
ans =
9
A
A =
1 3 5
9 7 -5
A(3)
ans =
3
A * 2 + 1
ans =
3 7 11
19 15 -9
whos
Name Size Bytes Class Attributes
A 2x3 48 double
a 1x1 8 double
ancestors 1x69 552 double
ans 2x3 48 double
b 1x1 8 double
c 1x16 128 double
etime 1x1 8 double
gen 1x1 8 double
A*b
ans =
34 102 170
306 238 -170
A*c
{Error using *
Inner matrix dimensions must agree.
}
C = [ 3, 4, 5; 9, 7, 5]
C =
3 4 5
9 7 5
A*C
{Error using *
Inner matrix dimensions must agree.
}
A
A =
1 3 5
9 7 -5
C2 = transpose(C)
C2 =
3 9
4 7
5 5
C
C =
3 4 5
9 7 5
whos
Name Size Bytes Class Attributes
A 2x3 48 double
C 2x3 48 double
C2 3x2 48 double
a 1x1 8 double
ancestors 1x69 552 double
ans 2x3 48 double
b 1x1 8 double
c 1x16 128 double
etime 1x1 8 double
gen 1x1 8 double
A * C2
ans =
40 55
30 105
A
A =
1 3 5
9 7 -5
C
C =
3 4 5
9 7 5
A * C
{Error using *
Inner matrix dimensions must agree.
}
A .* C
ans =
3 12 25
81 49 -25
D = [ 1:3; 5:7; 4:2:10]
{Error using vertcat
Dimensions of matrices being concatenated are not
consistent.
}
D = [ 1:3; 5:7; 4:2:8]
D =
1 2 3
5 6 7
4 6 8
A .* D
{Error using .*
Matrix dimensions must agree.
}
F = 1:9
F =
1 2 3 4 5 6 7 8 9
F .* D
{Error using .*
Matrix dimensions must agree.
}
A .* C
ans =
3 12 25
81 49 -25
A
A =
1 3 5
9 7 -5
C
C =
3 4 5
9 7 5
A .* C
ans =
3 12 25
81 49 -25
C
C =
3 4 5
9 7 5
C2 = transpose(C)
C2 =
3 9
4 7
5 5
C.'
ans =
3 9
4 7
5 5
F
F =
1 2 3 4 5 6 7 8 9
transpose(F)
ans =
1
2
3
4
5
6
7
8
9
A
A =
1 3 5
9 7 -5
transpose(A)
ans =
1 9
3 7
5 -5
A.'
ans =
1 9
3 7
5 -5
A
A =
1 3 5
9 7 -5
A(1,2) = 3 + 7j
A =
Column 1
1.000000000000000 + 0.000000000000000i
9.000000000000000 + 0.000000000000000i
Column 2
3.000000000000000 + 7.000000000000000i
7.000000000000000 + 0.000000000000000i
Column 3
5.000000000000000 + 0.000000000000000i
-5.000000000000000 + 0.000000000000000i
format short
A
A =
Columns 1 through 2
1.0000 + 0.0000i 3.0000 + 7.0000i
9.0000 + 0.0000i 7.0000 + 0.0000i
Column 3
5.0000 + 0.0000i
-5.0000 + 0.0000i
A.'
ans =
1.0000 + 0.0000i 9.0000 + 0.0000i
3.0000 + 7.0000i 7.0000 + 0.0000i
5.0000 + 0.0000i -5.0000 + 0.0000i
transpose(A)
ans =
1.0000 + 0.0000i 9.0000 + 0.0000i
3.0000 + 7.0000i 7.0000 + 0.0000i
5.0000 + 0.0000i -5.0000 + 0.0000i
A'
ans =
1.0000 + 0.0000i 9.0000 + 0.0000i
3.0000 - 7.0000i 7.0000 + 0.0000i
5.0000 + 0.0000i -5.0000 + 0.0000i
A.'
ans =
1.0000 + 0.0000i 9.0000 + 0.0000i
3.0000 + 7.0000i 7.0000 + 0.0000i
5.0000 + 0.0000i -5.0000 + 0.0000i
diary off