SP Solutions
SP Solutions
Solution
Coding
x=pi/5;
LHS=cos(x/2)^2
RHS=(tan(x)+sin(x))/(2*tan(x))
Result
LHS = 0.9045
RHS = 0.9045
Solution
Coding
C2C3=R2+R3; C3C4=R3+R4;
Gama1=acos((C1C2^2+C1C3^2-C2C3^2)/(2*C1C2*C1C3));
Gama2=acos((C1C3^2+C1C4^2-C3C4^2)/(2*C1C3*C1C4));
Gama3=Gama1+Gama2;
C2C4=sqrt(C1C2^2+C1C4^2-2*C1C2*C1C4*cos(Gama3))
Result
C2C4 = 33.5051
Solution
Coding
T=round(Ts+(T0-Ts)*exp(-k*t))
Result
T = 59
Solution
Coding
B=P*(1+r)^ta
t=log(B/P)/(n*log(1+r/n))
years=fix(t)
months=ceil((t-years)*12)
Result
B = 20011 or 2.0011e+04
t = 16.374
years = 16
months = 5
Chapter 2
Solution
Coding
A(1:2,:)=zeros(2,5)
A(3:4,:)=ones(2,5)
A=[zeros(2,5);ones(2,5)]
Result
A=
0 0 0 0 0
0 0 0 0 0
A=
0 0 0 0 0
0 0 0 0 0
1 1 1 1 1
1 1 1 1 1
A=
0 0 0 0 0
0 0 0 0 0
1 1 1 1 1
1 1 1 1 1
Solution
Coding
AR=zeros(6,6)
AR(3:4,:)=ones(2,6)
AR(:,3:4)=ones(6,2)
Result
AR =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
AR =
0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0
AR =
0 0 1 1 0 0
0 0 1 1 0 0
1 1 1 1 1 1
1 1 1 1 1 1
0 0 1 1 0 0
0 0 1 1 0 0
Solution
Coding
A=[2:3:17; 3:3:18; 4:3:19; 5:3:20; 6:3:21]
v=[99:-1:91]
Result
A=
2 5 8 11 14 17
3 6 9 12 15 18
4 7 10 13 16 19
5 8 11 14 17 20
6 9 12 15 18 21
B=
5 10 15 20 25 30
30 35 40 45 50 55
55 60 65 70 75 80
v=
99 98 97 96 95 94 93 92 91
A=
2 5 5 10 15 20
3 6 9 12 15 18
4 7 30 35 40 45
5 8 95 94 93 92
6 9 60 65 70 75
Chapter 3
Sample Problem 3.1
Solution
Coding
A=[4 -2 6; 2 8 2; 6 10 3];
B=[8; 4; 0];
X=A\B
Xb=inv(A)*B
D=[8 4 0];
Xc=D/C
Xd=D*inv(C)
Result
X=
-1.8049
0.2927
2.6341
Xb =
-1.8049
0.2927
2.6341
Xc =
Xd =
Solution
Coding
F1=F1M*[cosd(Th1) sind(Th1)]
F2=F2M*[cosd(Th2) sind(Th2)]
F3=F3M*[cosd(Th3) sind(Th3)]
Ftot=F1+F2+F3
FtotM=sqrt(Ftot(1)^2+Ftot(2)^2)
Th=atand(Ftot(2)/Ftot(1))
Result
F1 = 375.8770 -136.8081
F2 = 433.0127 250.0000
F3 = -559.0449 421.2705
FtotM = 589.9768
Th = 64.9453
Solution
Coding
m=[2 4 5 10 20 50];
mu=F./(m*9.81)
mu_ave=mean(mu)
Result
mu =
Solution
Coding
A=[-(R1+R2+R3) R2 R3 0
R2 -(R2+R4+R5+R7) R4 R7
R3 R4 -(R3+R4+R6) R6
0 R7 R6 -(R6+R7+R8)]
I=A\B
Result
A=
-44 10 16 0
10 -43 6 12
16 6 -30 8
0 12 8 -34
B=
-20
12
-40
I=
0.8411
0.7206
0.6127
1.5750
Solution
Coding
t=0:10;
y=-400+v0train*t;
x=-200+v0car*t+0.5*acar*t.^2;
d=sqrt(x.^2+y.^2);
vcar=v0car+acar*t;
speed_trainRcar=sqrt(vcar.^2+v0train^2);
Result
table =
Solution
Coding
theta=asin(r/R);
h=R*(1-cos(theta));
Vcap=pi*h^2*(3*R-h)/3;
H=(V-Vcap)/(pi*r^2);
S=2*pi*(r*H + R*h);
Result
Solution
Coding
%C=input('Enter a matrix in which each row has three elements.\nIn each row
enter the x and y coordinates of the centroid and the area of a section.\n');
%150 95 -40*150
%xs=C(:,1)';
%ys=C(:,2)';
%As=C(:,3)';
A=sum(As);
x=sum(As.*xs)/A;
y=sum(As.*ys)/A;
Result
Solution
Coding
Result
Resistance Voltage Power
(Ohms) (Volts) (Watts)
Solution
Coding
x=[-2:0.01:4];
y=3*x.^3-26*x+6;
yd=9*x.^2-26;
ydd=18*x;
plot(x,y,'-b',x,yd,'--r',x,ydd,':k')
Result
Sample Problem 5.2
Solution
Coding
THD=THDrpm*2*pi/60;
tf=2*pi/THD;
t=linspace(0,tf,200);
TH=THD*t;
d2s=c^2-r^2*sin(TH).^2;
x=r*cos(TH)+sqrt(d2s);
xd=-r*THD*sin(TH)-(r^2*THD*sin(2*TH))./(2*sqrt(d2s));
xdd=-r*THD^2*cos(TH)-
(4*r^2*THD^2*cos(2*TH).*d2s+(r^2*sin(2*TH)*THD).^2)./(4*d2s.^(3/2));
subplot(3,1,1)
plot(t,x)
grid
xlabel('Time (s)')
ylabel('Position (m)')
subplot(3,1,2)
plot(t,xd)
grid
xlabel('Time (s)')
ylabel('Velocity (m/s)')
subplot(3,1,3)
plot(t,xdd)
grid
xlabel('Time (s)')
ylabel('Acceleration (m/s^2)')
Result
Sample Problem 5.3
Solution
Coding
q=12e-9;
epsilon0=8.8541878e-12;
x=[-0.05:0.001:0.05]';
rminusS=(0.02-x).^2+0.02^2; rminus=sqrt(rminusS);
rplusS=(x+0.02).^2+0.02^2; rplus=sqrt(rplusS);
EminusUV=[((0.02-x)./rminus), (-0.02./rminus)];
EplusUV=[((x+0.02)./rplus), (0.02./rplus)];
EminusMAG=(q/(4*pi*epsilon0))./rminusS;
EplusMAG=(q/(4*pi*epsilon0))./rplusS;
Eminus=[EminusMAG.*EminusUV(:,1), EminusMAG.*EminusUV(:,2)];
Eplus=[EplusMAG.*EplusUV(:,1), EplusMAG.*EplusUV(:,2)];
E=Eminus+Eplus;
EMAG=sqrt(E(:,1).^2+E(:,2).^2);
plot(x,EMAG,'k','linewidth',1)
Result
Chapter 6
Sample Problem 6.1
Solution
Function File
function y=chp6one(x)
y=(x.^4.*sqrt(3*x+5))./(x.^2+1).^2;
Script File
chp6one(6)
F=chp6one(6)
x=1:2:11
chp6one(x)
Result
ans = 4.5401
F = 4.5401
x= 1 3 5 7 9 11
ans =
Solution
Function File
function C=FtoC(F)
%FtoC converts degrees F to degrees C
C=5*(F-32)./9;
Script File
deltaT=FtoC(T2)-FtoC(T1);
a2=a1+alpha*a1*deltaT;
b2=b1+alpha*b1*deltaT;
AreaChange=a2*b2-a1*b1;
Result
Solution
Coding
d= @ (rA,thetA,rB,thetB) sqrt(rA^2+rB^2-2*rA*rB*cos(thetB-thetA))
DistAtoB = d(2,pi/6,5,3*pi/4)
Result
d=
@(rA,thetA,rB,thetB)sqrt(rA^2+rB^2-2*rA*rB*cos(thetB-thetA))
DistAtoB = 5.8461
Solution
Function File
n=length(v);
me=AVG(v,n);
SD=StandDiv(v,me,n);
function av=AVG(x,num)
av=sum(x)/num;
function Sdiv=StandDiv(x,xAve,num)
xdif=x-xAve;
xdif2=xdif.^2;
Sdiv= sqrt(sum(xdif2)/(num-1));
Script File
Grades=[80 75 91 60 79 89 65 80 95 50 81];
Result
AveGrade = 76.8182
StanDeviation = 13.6661
Sample Problem 6.5
Solution
Function File
function At=expGD(A0,At1,t1,t)
% t: time t.
k=log(At1/A0)/t1;
At=A0*exp(k*t);
Script File
expGD(67,79,6,20)
expGD(7,3.5,5.8,30)
Result
ans = 116.0332
ans = 0.1941
Solution
Function File
function [hmax,dmax]=trajectory(v0,theta)
g=9.81;
v0x=v0*cos(theta*pi/180);
v0y=v0*sin(theta*pi/180);
thmax=v0y/g;
hmax=v0y^2/(2*g);
ttot=2*thmax;
dmax=v0x*ttot;
tplot=linspace(0,ttot,200);
x=v0x*tplot;
y=v0y*tplot-0.5*g*tplot.^2;
plot(x,y)
xlabel('DISTANCE (m)')
ylabel('HEIGHT (m)')
title('PROJECTILE''S TRAJECTORY')
Script File
[h d]=trajectory(230,39)
Result
h = 1.0678e+03
d = 5.2746e+03