0% found this document useful (0 votes)
11 views32 pages

SP Solutions

The document presents a series of sample problems and solutions across multiple chapters, focusing on mathematical and engineering concepts such as trigonometry, matrix operations, and circuit analysis. Each problem includes coding examples, calculations, and results, demonstrating practical applications of the theories discussed. The document serves as a resource for understanding complex mathematical operations and their implementations in programming.
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)
11 views32 pages

SP Solutions

The document presents a series of sample problems and solutions across multiple chapters, focusing on mathematical and engineering concepts such as trigonometry, matrix operations, and circuit analysis. Each problem includes coding examples, calculations, and results, demonstrating practical applications of the theories discussed. The document serves as a resource for understanding complex mathematical operations and their implementations in programming.
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/ 32

Chapter 1

Sample Problem 1.1

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

Sample Problem 1.2

Solution

Coding

%R1=16; R2=6.5; R3=12; R4=9.5;

R1=16; R2=6.5; R3=12; R4=9.5;

C1C2=R1+R2; C1C3=R1+R3; C1C4=R1+R4;

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

Sample Problem 1.3

Solution

Coding

Ts=38; T0=120; k=0.45; t=3;

T=round(Ts+(T0-Ts)*exp(-k*t))

Result

T = 59

Sample Problem 1.4

Solution

Coding

P=5000; r=0.085; ta=17; n=12;

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

Sample Problem 2.1

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

Sample Problem 2.2

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

Sample Problem 2.3

Solution

Coding
A=[2:3:17; 3:3:18; 4:3:19; 5:3:20; 6:3:21]

B=[5:5:30; 30:5:55; 55:5:80]

v=[99:-1:91]

A([1 3 4 5],3:6)=[B([1 2],1:4); v(5:8); B(3,2:5)]

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

C=[4 2 6; -2 8 10; 6 2 3];

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 =

-1.8049 0.2927 2.6341

Xd =

-1.8049 0.2927 2.6341

Sample Problem 3.2

Solution

Coding

F1M=400; F2M=500; F3M=700;

Th1=-20; Th2=30; Th3=143;

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

Ftot = 249.8449 534.4625

FtotM = 589.9768

Th = 64.9453

Sample Problem 3.3

Solution

Coding

m=[2 4 5 10 20 50];

F=[12.5 23.5 30 61 117 294];

mu=F./(m*9.81)

mu_ave=mean(mu)

Result

mu =

0.6371 0.5989 0.6116 0.6218 0.5963 0.5994


mu_ave = 0.6109

Sample Problem 3.4

Solution

Coding

V1=20; V2=12; V3=40;

R1=18; R2=10; R3=16; R4=6;

R5=15; R6=8; R7=12; R8=14;

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)]

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

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

Sample Problem 3.5

Solution

Coding

v0train=54*5280/3600; v0car=28*5280/3600; acar=4;

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);

table=[t' y' x' d' vcar' speed_trainRcar']

Result

table =

0 -400.0000 -200.0000 447.2136 41.0667 89.2139

1.0000 -320.8000 -156.9333 357.1284 45.0667 91.1243

2.0000 -241.6000 -109.8667 265.4077 49.0667 93.1675

3.0000 -162.4000 -58.8000 172.7171 53.0667 95.3347

4.0000 -83.2000 -3.7333 83.2837 57.0667 97.6178

5.0000 -4.0000 55.3333 55.4777 61.0667 100.0089

6.0000 75.2000 118.4000 140.2626 65.0667 102.5003

7.0000 154.4000 185.4667 241.3239 69.0667 105.0849

8.0000 233.6000 256.5333 346.9558 73.0667 107.7561

9.0000 312.8000 331.6000 455.8535 77.0667 110.5075

10.0000 392.0000 410.6667 567.7245 81.0667 113.3333


Chapter 4
Sample Problem 4.1

Solution

Coding

r=30; R=45; V=200000;

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);

fprintf('The height H is: %f ft.',H)

fprintf('\nThe surface area of the silo is: %f square ft.',S)

Result

The height H is: 64.727400 ft.

The surface area of the silo is: 15440.777753 square ft.


Sample Problem 4.2

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');

xs=[100 60-120/pi 60+140/3 100 150 105];

ys=[100 200+120/pi 220 100/pi 95 145];

As=[200*200 pi*60^2/4 140*60/2 -pi*50^2/2 -40*150 -50*50];

%xy=[100 100 200*200

%60-120/pi 200+120/pi pi*60^2/4

%60+140/3 220 140*60/2

%100 100/pi -pi*50^2/2

%150 95 -40*150

%105 145 -50*50] ;

%xs=C(:,1)';

%ys=C(:,2)';

%As=C(:,3)';

A=sum(As);

x=sum(As.*xs)/A;
y=sum(As.*ys)/A;

fprintf('The coordinates of the centroid are: ( %f, %f )',x,y)

Result

The coordinates of the centroid are: ( 85.387547, 131.211809 )

Sample Problem 4.3

Solution

Coding

% The program calculates the voltage across each resistor


% in a circuit that has resistors connected in series.
%vs=input('Please enter the source voltage ');
vs=24;
Rn=[20 14 12 18 8 15 10];
%Rn=input('Enter the values of the resistors as elements in a row vector\n');
Req=sum(Rn);
vn=Rn*vs/Req;
Pn=Rn*vs^2/Req^2;
i = vs/Req;
Ptotal = vs*i;
Table = [Rn', vn', Pn'];
disp(' ')
disp(' Resistance Voltage Power')
disp(' (Ohms) (Volts) (Watts)')
disp(' ')
disp(Table)
disp(' ')
fprintf('The current in the circuit is %f Amps.',i)
fprintf('\nThe total power dissipated in the circuit is %f Watts.',Ptotal)

Result
Resistance Voltage Power
(Ohms) (Volts) (Watts)

20.0000 4.9485 1.2244


14.0000 3.4639 0.8571
12.0000 2.9691 0.7346
18.0000 4.4536 1.1019
8.0000 1.9794 0.4897
15.0000 3.7113 0.9183
10.0000 2.4742 0.6122

The current in the circuit is 0.247423 Amps.


The total power dissipated in the circuit is 5.938144 Watts.
Chapter 5
Sample Problem 5.1

Solution

Coding

%The first derivative of the function is:y'=9x^2-26

%The second derivative of the function is:y"=18x

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

THDrpm=500; r=0.12; c=0.25;

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)

xlabel('Position along the x-axis (m)','FontSize',12)

ylabel('Magnitude of the electric field (N/C)','FontSize',12)


title('ELECTRIC FIELD DUE TO AN ELECTRIC DIPOLE','FontSize',12)

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 =

0.7071 3.0307 4.1347 4.8971 5.5197 6.0638


Sample Problem 6.2

Solution

Function File

function C=FtoC(F)
%FtoC converts degrees F to degrees C
C=5*(F-32)./9;

Script File

a1=4.5; b1=2.25; T1=40; T2=92; alpha=23e-6;

deltaT=FtoC(T2)-FtoC(T1);

a2=a1+alpha*a1*deltaT;

b2=b1+alpha*b1*deltaT;

AreaChange=a2*b2-a1*b1;

fprintf('The change in the area is %6.5f meters square.',AreaChange)

Result

The change in the area is 0.01346 meters square.


Sample Problem 6.3

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=

function_handle with value:

@(rA,thetA,rB,thetB)sqrt(rA^2+rB^2-2*rA*rB*cos(thetB-thetA))

DistAtoB = 5.8461

Sample Problem 6.4

Solution

Function File

function [me SD] = stat(v)

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];

[AveGrade StanDeviation] = stat(Grades)

Result

AveGrade = 76.8182

StanDeviation = 13.6661
Sample Problem 6.5

Solution

Function File

function At=expGD(A0,At1,t1,t)

% expGD calculates exponential growth and decay

% Input arguments are:

% A0: Quantity at time zero.

% At1: Quantity at time t1.

% t1: The time t1.

% t: time t.

% Output argument is:

% At: Quantity at 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

Sample Problem 6.6

Solution

Function File

function [hmax,dmax]=trajectory(v0,theta)

% trajectory calculates the max height and distance of a projectile, and


makes a plot of the trajectory.

% Input arguments are:

% v0: initial velocity in (m/s).

% theta: angle in degrees.

% Output arguments are:

% hmax: maximum height in (m).

% dmax: maximum distance in (m).

% The function creates also a plot of the trajectory.

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;

% Creating a trajectory plot

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

You might also like