0% found this document useful (0 votes)
91 views16 pages

Solved Problems: Problem 1

This document contains 19 solved problems involving MATLAB code and calculations. Problem 1-18 involve MATLAB code to calculate and solve various equations, while Problem 19 sets up a circuit diagram with voltage and resistor values.

Uploaded by

손민석
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views16 pages

Solved Problems: Problem 1

This document contains 19 solved problems involving MATLAB code and calculations. Problem 1-18 involve MATLAB code to calculate and solve various equations, while Problem 19 sets up a circuit diagram with voltage and resistor values.

Uploaded by

손민석
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Chapter 3

Solved Problems

Problem 1
>> x=-2:5;
>> y=(2*x.^2-5*x+4).^3./x.^2
y =
1.0e+003 *
2.6620 1.3310 Inf 0.0010 0.0020 0.0381
0.2560 0.9756

Problem 2
>> t=0:8;
>> y=5*sqrt(t)-(t+1).^2/0.5./(t+1)+8
y =
6.0000 9.0000 9.0711 8.6603 8.0000 7.1803
6.2474 5.2288 4.1421

1
2 Chapter 3: Solved Problems

Problem 3
>> n=1:8;
>> hmax=2*.85.^(2*n)
hmax =
1.4450 1.0440 0.7543 0.5450 0.3937 0.2845
0.2055 0.1485

Problem 4
Script file:
g=9.81; m=.624; Cd = 0.5;
rho = 1.2; r = 0.117;
A = pi*r^2;
t = 0:10;
v = sqrt(2*m*g/rho/A/Cd)*(1-exp(-sqrt(rho*g*Cd*A/2/m)*t))

Command Window:
v =
0 7.8984 12.9328 16.1417 18.1870 19.4907
20.3217 20.8513 21.1889 21.4041 21.5413

Problem 5
5.a
>> u=[14 25 -10]; sqrt(u(1)^2+u(2)^2+u(3)^2)
ans =
30.3480

5.b
>> sqrt(sum([14 25 -10].^2))
ans =
30.3480
Chapter 3: Solved Problems 3

Problem 6
Script file:
g=9.81; q=79; v0=100;
t=0:2:20;
x=v0*cosd(q)*t;
y=v0*sind(q)*t-g*t.^2/2;
r=sqrt(x.^2+y.^2)

Command Window:
r =
0 180.7792 323.3089 427.9925 495.4815 526.8909
524.2756 491.7770 438.6131 386.7074 381.6201

Problem 7
>> u = [4 9 -5]; v = [-3; 6; -7];

7.a
>> u*v
ans =
77

7.b
>> dot(u,v)
ans =
77
4 Chapter 3: Solved Problems

Problem 8
Script file:
x=2:2:10; y =3:3:15;
z=(y./x).^2+(x+y).^((y-x)./x)

Command Window:
z =
4.4861 5.4123 6.1230 6.7221 7.2500

Problem 9
>> h = 0.7; k = 8.85;
>> x=1:5; y=2.1:-.1:1.7; z=2:.5:4;
>> G=(h*x+k*y)./(x+y).^h + exp(h*y./z)./z.^(y./x)
G =
9.2215 7.9378 6.9952 6.2876 5.7379

Problem 10
>> format long
>> x=[1 0.5 0.1 0.01 0.001 0.00001 0.0000001];
>> y = (exp(x)-1)./x
y =
Columns 1 through 5
1.718281828459046 1.297442541400256 1.051709180756477
1.005016708416795 1.000500166708385
Columns 6 through 7
1.000005000006965 1.000000049433680
Chapter 3: Solved Problems 5

Problem 11
>> format long

11.a
>> n=0:1:100;
>> s=(-1).^n./(2*n+1);
>> 4*sum(s)
ans =
3.151493401070991
>> Error=(ans-pi)/pi*100
Error =
0.315150580387468

11.b
>> n=0:1:10000;
>> s=(-1).^n./(2*n+1);
>> 4*sum(s)
ans =
3.141692643590535
>> Error=(ans-pi)/pi*100
Error =
0.003182780575553

11.c
>> n=0:1:1000000;
>> s=(-1).^n./(2*n+1);
>> 4*sum(s)
ans =
3.141593653588775
>> Error=(ans-pi)/pi*100
Error =
3.183095619530639e-005
6 Chapter 3: Solved Problems

Problem 12
Script file:
% HW 3_12 Solution
n = 0:N; % N is specified in the command window
s = 1./(2*n+1)./(2*n+2);
est_val = sum(s)
act_val = log(2)
percent_error = abs(est_val-act_val)/act_val*100

12.a
>> N=50;
>> HW3_12Script
est_val =
0.688269247840578
act_val =
0.693147180559945
percent_error =
0.703736934402188

12.b
>> N=500;
>> HW3_12Script
est_val =
0.692648427566807
act_val =
0.693147180559945
percent_error =
0.071954846982977

12.c
>> N=5000;
>> HW3_12Script
est_val =
0.693097193056947
act_val =
0.693147180559945
percent_error =
0.007211672268245
Chapter 3: Solved Problems 7

Problem 13
13.a
>> K=0.25; L = 50*(1-exp(-K*(2+0.5)))
L =
23.2369

Answer: 23.2 cm

13.b
>> K=0.5; L = 50*(1-exp(-K*(2+0.5)))
L =
35.6748

Answer: 35.7 cm

13.c
>> K=0.75; L = 50*(1-exp(-K*(2+0.5)))
L =
42.3323

Answer: 42.3 cm
8 Chapter 3: Solved Problems

Problem 14
>> A=[5 2 4; 1 7 -3; 6 -10 0];
>> B=[11 5 -3; 0 -12 4; 2 6 1];
>> C=[7 14 1; 10 3 -2; 8 -5 9];

14.a
>> A+B
ans =
16 7 1
1 -5 1
8 -4 1
>> B+A
ans =
16 7 1
1 -5 1
8 -4 1

14.b
>> A+(B+C)
ans =
23 21 2
11 -2 -1
16 -9 10
>> (A+B)+C
ans =
23 21 2
11 -2 -1
16 -9 10

9.c
>> 5*(A+C)
ans =
60 80 25
55 50 -25
70 -75 45
>> 5*A+5*C
ans =
60 80 25
55 50 -25
70 -75 45

9.d
>> A*(B+C)
ans =
150 81 34
Chapter 3: Solved Problems 9

58 -47 -18
8 204 -32
>> A*B+A*C
ans =
150 81 34
58 -47 -18
8 204 -32
10 Chapter 3: Solved Problems

Problem 15
>> A=[5 2 4; 1 7 -3; 6 -10 0];
>> B=[11 5 -3; 0 -12 4; 2 6 1];
>> C=[7 14 1; 10 3 -2; 8 -5 9];

15.a
>> A*B
ans =
63 25 -3
5 -97 22
66 150 -58

>> B*A
ans =
42 87 29
12 -124 36
22 36 -10

Answer: No, A*B does not equal B*A

15.b
>> A*(B*C)
ans =
667 972 -14
-759 -331 397
1498 1664 -756

>> (A*B)*C
ans =
667 972 -14
-759 -331 397
1498 1664 -756

Answer: Yes, A*(B*C) does equal (A*B)*C

15.c

>> (A*B)'
ans =
63 5 66
25 -97 150
-3 22 -58

>> B'*A'
ans =
Chapter 3: Solved Problems 11

63 5 66
25 -97 150
-3 22 -58

Answer: Yes, (A*B)t does equal Bt*At

15.d
EDU" (A+B)'
ans =
16 1 8
7 -5 -4
1 1 1

EDU" A'+B'
ans =
16 1 8
7 -5 -4
1 1 1

Answer: Yes, (A+B)t does equal At+Bt


12 Chapter 3: Solved Problems

Problem 16
Command Window:
>> g=9.81; vA=680; THA=65; vB=780; THB=42;
>> vAx0=vA*cosd(THA); vAy0=vA*sind(THA);
>> vBx0=vB*cosd(THB); vBy0=vB*sind(THB);
>> tAup=vAy0/g
tAup =
62.8226
>> tBup=vBy0/g
tBup =
53.2030
>> % Projectile B will hit the ground first.
>> tf=2*tBup;
>> t=linspace(0,tf,11);
>> xA=vAx0*t;
>> yA=vAy0*t-0.5*g*t.^2;
>> xB=vBx0*t;
>> yB=vBy0*t-0.5*g*t.^2;
>> d=sqrt((xB-xA).^2+(yB-yA).^2);
>> format short e
>> Table=[t' d']
Table =
0 0
1.0641e+001 3.2680e+003
2.1281e+001 6.5361e+003
3.1922e+001 9.8041e+003
4.2562e+001 1.3072e+004
5.3203e+001 1.6340e+004
6.3844e+001 1.9608e+004
7.4484e+001 2.2876e+004
8.5125e+001 2.6144e+004
9.5765e+001 2.9412e+004
1.0641e+002 3.2680e+004
Chapter 3: Solved Problems 13

Problem 17
Script file:
u=0:.05:1;
k=.25;
p=k*u.*(1-u)./(k+u);
pmax05 = max(p)
u=0:.01:1;
p=k*u.*(1-u)./(k+u);
pmax01 = max(p)
E = abs((pmax01-pmax05)/pmax01)*100

Command Window:
>> format long
pmax05 =
0.095454545454545
pmax01 =
0.095491071428571
E =
0.038250669386692
14 Chapter 3: Solved Problems

Problem 18
Command Window:
>> A=[1.5 -2 1 3 .5
3 1 -1 4 -3
2 6 -3 -1 3
5 2 4 -2 6
-3 3 2 5 4]
A =
1.5000 -2.0000 1.0000 3.0000 0.5000
3.0000 1.0000 -1.0000 4.0000 -3.0000
2.0000 6.0000 -3.0000 -1.0000 3.0000
5.0000 2.0000 4.0000 -2.0000 6.0000
-3.0000 3.0000 2.0000 5.0000 4.0000
>> B=[7.5; 16; 78; 71; 54]
B =
7.5000
16.0000
78.0000
71.0000
54.0000
>> Solution=A\B
Solution =
5.0000
7.0000
-2.0000
4.0000
8.0000
Chapter 3: Solved Problems 15

Problem 19
R1

Script file: i1
V1
_
+
V1=38; V2=20; V3=24;
R2
R1=15; R2=18; R3=10; R4=9;
R5=5; R6=14; R7=8; R8=13;
+
A=[-(R1+R2) R2 0 0 0 R8 i5 R7 i2 V2 _
0 -(R3+R4+R7) R4 R3 R7 R3 R4
0 R4 -(R4+R5) R5 0
0 R3 R5 -(R3+R5+R6) R6
R6 i4 R5 i3 V
_
0 R7 0 R6 -(R6+R7+R8)]
+
3

B=[V1; V2; -V3; 0; -V1]


I=A\B
% A table with the value of the current in each resistor
RI=[1 I(1)
2 abs(I(1)-I(2))
3 abs(I(1)-I(4))
4 abs(I(1)-I(3))
5 abs(I(3)-I(4))
6 abs(I(4)-I(5))
7 abs(I(2)-I(5))
8 abs(I(5))]

Command Window:
A =
-33 18 0 0 0
0 -27 9 10 8
0 9 -14 5 0
0 10 5 -29 14
0 8 0 14 -35
B =
38
20
-24
0
-38
I =
0.5956
16 Chapter 3: Solved Problems

3.2031
5.0350
3.5323
3.2308
RI =
1.0000 0.5956
2.0000 2.6075
3.0000 2.9367
4.0000 4.4393
5.0000 1.5027
6.0000 0.3015
7.0000 0.0277
8.0000 3.2308

You might also like