Uploaded by Caitlin Lim

Homework1 MAE8

advertisement
Homework 1
Table of Contents
Problem
Problem
Problem
Problem
Problem
Problem
Problem
Problem
Problem
Problem
1 ..........................................................................................................................
2 ..........................................................................................................................
3 ..........................................................................................................................
4 ..........................................................................................................................
5 ..........................................................................................................................
6 ..........................................................................................................................
7 ..........................................................................................................................
8 ..........................................................................................................................
9 ..........................................................................................................................
10 ........................................................................................................................
Problem 1
tan(pi/4)
sqrt(20)
8.2^(-0.4)
exp(1i*pi)
ans =
1.0000
ans =
4.4721
ans =
0.4310
ans =
-1.0000 + 0.0000i
Problem 2
nthroot(14641, 4)
nthroot(343, 3)
1
1
1
2
2
3
4
4
4
5
5
Homework 1
nthroot(7776, 5)
ans =
11
ans =
7
ans =
6
Problem 3
rand * (9-3) + 3
rand * (0.2 + 10.5) - 10.5
round(rand * (5+5) - 5)
randi([-5,5])
ans =
6.9344
ans =
-10.1179
ans =
3
ans =
5
Problem 4
r = 4.3 % centimeters
r = r * .01 % meters
h = 125.7 % millimeters
h = h * .001 % meters
2
Homework 1
vol = pi * r^2 * h
s_a = 2 * pi * r * h
r =
4.3000
r =
0.0430
h =
125.7000
h =
0.1257
vol =
7.3017e-04
s_a =
0.0340
Problem 5
A = true
(A || A) == (xor(A,A))
%% logical 0 --> false, they are not equal
A =
logical
1
ans =
logical
3
Homework 1
0
Problem 6
row = linspace(33,34,11)
row =
Columns 1 through 7
33.0000
33.1000
33.2000
33.3000
33.9000
34.0000
Columns 8 through 11
33.7000
33.8000
Problem 7
col = (-12:3:9)'
col =
-12
-9
-6
-3
0
3
6
9
Problem 8
linspace(3,23,6)
3:4:23
ans =
3
7
11
15
19
23
7
11
15
19
23
ans =
3
4
33.4000
33.5000
33.6000
Homework 1
Problem 9
x = [ linspace(23, 11, 7) ; linspace( (-1*pi/2), pi, 7) ;
linspace(5.5, 6.1, 7) ]
x =
23.0000
-1.5708
5.5000
21.0000
-0.7854
5.6000
19.0000
0
5.7000
17.0000
0.7854
5.8000
Problem 10
x(2, 5)
x(1, 3)
x(:, [2,end])
x([1,2], [2,3])
x(end, [2,4,6])
ans =
1.5708
ans =
19
ans =
21.0000
-0.7854
5.6000
11.0000
3.1416
6.1000
ans =
21.0000
-0.7854
19.0000
0
ans =
5.6000
5.8000
6.0000
Published with MATLAB® R2019b
5
15.0000
1.5708
5.9000
13.0000
2.3562
6.0000
11.0000
3.1416
6.1000
Download