% See if this text appears
% in Lecture3.txt
pathtool;
figure
pathtool;
5+7
ans =
12
ans
ans =
12
5+7=x
??? 5+7=x
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.
x=5+7
x =
12
y=6+7;
y
y =
13
y = 6 + 8
y =
14
Y = 6+9
Y =
15
y
y =
14
Y
Y =
15
y = 6 + 10
y =
16
a = 7, b = 5
a =
7
b =
5
a = 8; b = 9
b =
9
pi
ans =
3.1416
format long
pi
ans =
3.141592653589793
format long e
pi
ans =
3.141592653589793e+000
z = 1e-4
z =
1.000000000000000e-004
z = 0.0001
z =
1.000000000000000e-004
format long
z
z =
1.000000000000000e-004
format short
z
z =
1.0000e-004
format short g
z
z =
0.0001
format short e
z
z =
1.0000e-004
format short
z
z =
1.0000e-004
format bank
x = 1.23
x =
1.23
format short
eps
ans =
2.2204e-016
x
x =
1.2300
y = 3+5*i
y =
3.0000 + 5.0000i
a = [1 2 3 4]
a =
1 2 3 4
a = [1 2 3 4]'
a =
1
2
3
4
a = [1 2 3 4]
a =
1 2 3 4
b = [5
6
7
8]
b =
5
6
7
8
clear b
b
??? Undefined function or variable 'b'.
b = [5; 6; 7; 8]
b =
5
6
7
8
A = [1 2 3 4; 5 6 7 8]
A =
1 2 3 4
5 6 7 8
B = zeros(3,3)
B =
0 0 0
0 0 0
0 0 0
C = ones(4,3)
C =
1 1 1
1 1 1
1 1 1
1 1 1
openvar('a', a);
openvar('Y', Y);
who
Your variables are:
A Y b z
B a x
C ans y
whos
Name Size Bytes Class Attributes
A 2x4 64 double
B 3x3 72 double
C 4x3 96 double
Y 1x1 8 double
a 1x4 32 double
ans 1x1 8 double
b 4x1 32 double
x 1x1 8 double
y 1x1 16 double complex
z 1x1 8 double
t = 0:10
t =
Columns 1 through 4
0 1 2 3
Columns 5 through 8
4 5 6 7
Columns 9 through 11
8 9 10
t = t'
t =
0
1
2
3
4
5
6
7
8
9
10
t = 0:0.5:5'
t =
Columns 1 through 2
0 0.5000
Columns 3 through 4
1.0000 1.5000
Columns 5 through 6
2.0000 2.5000
Columns 7 through 8
3.0000 3.5000
Columns 9 through 10
4.0000 4.5000
Column 11
5.0000
t = (0:0.5:5)'
t =
0
0.5000
1.0000
1.5000
2.0000
2.5000
3.0000
3.5000
4.0000
4.5000
5.0000
u = linspace(0,5,11)'
u =
0
0.5000
1.0000
1.5000
2.0000
2.5000
3.0000
3.5000
4.0000
4.5000
5.0000
A
A =
1 2 3 4
5 6 7 8
A(1,2) = 5
A =
1 5 3 4
5 6 7 8
A(1,1:2) = [5 7]
A =
5 7 3 4
5 6 7 8
3^2
ans =
9
4-3*2
ans =
-2
a
a =
1 2 3 4
b
b =
5
6
7
8
a*b
ans =
70
b*a
ans =
5 10 15 20
6 12 18 24
7 14 21 28
8 16 24 32
a.*b
??? Error using ==> times
Matrix dimensions must agree.
a
a =
1 2 3 4
a.*b'
ans =
5 12 21 32
A
A =
5 7 3 4
5 6 7 8
C = [1 2 3; 4 5 6; 7 8 9]
C =
1 2 3
4 5 6
7 8 9
C*C
ans =
30 36 42
66 81 96
102 126 150
C^2
ans =
30 36 42
66 81 96
102 126 150
C.^2
ans =
1 4 9
16 25 36
49 64 81
help sin
SIN Sine of argument in radians.
SIN(X) is the sine of the elements of X.
See also asin, sind.
Reference page in Help browser
doc sin
x = linspace(0,2*pi,11)'
x =
0
0.6283
1.2566
1.8850
2.5133
3.1416
3.7699
4.3982
5.0265
5.6549
6.2832
y = sin(x)
y =
0
0.5878
0.9511
0.9511
0.5878
0.0000
-0.5878
-0.9511
-0.9511
-0.5878
-0.0000
x = [1.1 2.2 3.3 4.4 5.5 6.6 7.7]'
x =
1.1000
2.2000
3.3000
4.4000
5.5000
6.6000
7.7000
round(x)
ans =
1
2
3
4
6
7
8
floor(x)
ans =
1
2
3
4
5
6
7
ceil(x)
ans =
2
3
4
5
6
7
8
min(x)
ans =
1.1000
max(x)
ans =
7.7000
mean(x)
ans =
4.4000
std(x)
ans =
2.3763
y = rand(5,1)
y =
0.8147
0.9058
0.1270
0.9134
0.6324
sort(y)
ans =
0.1270
0.6324
0.8147
0.9058
0.9134
lookfor skydiver
fixedpt_skydiver.m: % Function fixedpt_skydiver
iterate_euler.m: % Program to solve the skydiver problem repeatedly
newton_skydiver.m: % Function newton_skydiver
skydiver_func1.m: % Function skydiver_func1
skydiver_func2.m: % Function skydiver_func2
z = cos(x)
z =
0.4536
-0.5885
-0.9875
-0.3073
0.7087
0.9502
0.1534
plot(x,y)
??? Error using ==> plot
Vectors must be the same lengths.
x
x =
1.1000
2.2000
3.3000
4.4000
5.5000
6.6000
7.7000
y
y =
0.8147
0.9058
0.1270
0.9134
0.6324
y = sin(x)
y =
0.8912
0.8085
-0.1577
-0.9516
-0.7055
0.3115
0.9882
plot(x,y)
clear all
x = linspace(0,2*pi,101)';
y = sin(x);
z = cos(x);
plot(x,y)
plot(x,z)
plot(x,y)
figure
plot(x,z)
plot(x,y)
hold on
plot(x,z)
plot(x,y,'r-')
plot(x,z,'g.')
plot(x,y,'r-')
hold on
plot(x,z,'g.')
plot(x,y,'r-',x,z,'bx')
title('Test plot')
xlabel('x axis (radians)')
ylabel('y axis (units)')
diary off