Chapter5

Click here to see book problems

Problem 1

Script file:

%problem 1  Use the plot command to plot the function
%when x is less than or equal to 5, and greater than or equal to 0.
%type [0 5]page 141
figure(1)
  fplot(@ (x) x.^2-10.*sqrt(x)+2,[0 5])

Problem 2

Script file:

%problem 2
figure(2)
x = -3:0.01:10;
y = (0.5*x.^4 + 1.1*(x.^3)-0.9*(x.^2)).*exp(-0.7*x);
plot(x,y)

Problem 3

Script file:

%problem 3
figure(3)
fplot(@ (x) 3.*cos(1.7*x).*exp(-0.3*x)+2.*sin(1.4*x).*exp(0.3*x),[-7 7])

Problem 4

Script file:

%problem 4
figure(4)
x=[0:0.01:10];
y=x.^2.*exp(-x);
yd=2.*x.*exp(-x)-exp(-x).*x.^2;
plot(x,y,’-‘, x,yd,’–‘)

Problem 5

Script file:

%problem 5
figure(5)
x1=[-3:0.01:4];
x2=[0:0.01:1];
y1= x1.^4-2.*x1.^3+1.3.*x1.^2-0.3.*x1+0.02;
y2= x2.^4-2.*x2.^3+1.3.*x2.^2-0.3.*x2+0.02;
plot(x1,y1)
plot(x2,y2)

Problem 6

Script file:

%problem 6
figure(6)
fplot(@ (x) 5*(exp(-0.5*x)-exp(-0.8*x)),[0 10])

Problem 7

Script file:

%problem 7
figure(7)
x = -pi:0.01:2*pi;
y = sin(2*x).*(cos(0.5*x)).^2;
yd = ((2.*(cos((0.5).*x).^2).*cos(2.*x))-(0.5.*sin(x).*sin(2.*x)));
plot(x,y,’-‘,x,yd,’–‘);

Problem 8

Script file:

%problem 8
figure(8)
th=linspace(0,2*pi,200);
r=3.44e7./(1-0.206*cos(th));
polar(th,r)

Problem 9

Script file:

%problem 9
figure(9)
t = [0:0.01:2*pi];
x = 0.7*sin(10*t);
y = 1.2*sin(8*t);
plot(x,y);
axis([-1.5, 1.5, -1.5, 1.5]);

Problem 10

Script file:

%problem 10
figure(10)
t = [0:0.01:2*pi];
x = sin(t).*((exp(cos(t))-(2.*cos(4.*t))+((sin(t./12)).^5)));
y = cos(t).*((exp(cos(t))-(2.*cos(4.*t))+((sin(t./12)).^5)));
subplot(2,1,1);
plot(x,y)
t = [0:0.01:10*pi];
x = sin(t).*((exp(cos(t))-(2.*cos(4.*t))+((sin(t./12)).^5)));
y = cos(t).*((exp(cos(t))-(2.*cos(4.*t))+((sin(t./12)).^5)));
subplot(2,1,2)
plot(x,y)

Problem 11

Script file:

%problem 11
figure(11)
x = 0: 0.01 : 1;
y = (1-x.^(2/3)).^(3/2);
yn = -y;
xn = 0: -0.01: -1;
plot(x,y,’k’,x,yn,’k’,xn,y,’k’,xn,yn,’k’)
axis square

Problem 12

Script file:

%problem 12
figure (12)
xi = -pi:0.01:pi;
x = (cos(xi)).^3;
y = (sin(xi)).^3;
plot(x,y);
axis([-1.5, 1.5, -1.5, 1.5]);

Problem 13

Script file:

%problem 13
figure (13)
x1=0:0.01:1.9;
x2=2.1:0.01:4;
y1= (x1.^2-6*x1+7)./(x1.^3-8);
y2= (x2.^2-6*x2+7)./(x2.^3-8);
plot(x1, y1, x2, y2)

Problem 14

Script file:

%problem 14
figure(14)
x1=[-4:0.005:-1.01];
x2=[-0.99:0.005:0.99];
x3=[1.01:0.005:4];
y1=x1+(1./(x1.^2-1));
y2=x2+(1./(x2.^2-1));
y3=x3+(1./(x3.^2-1));
plot(x1, y1, ‘k’, x2, y2, ‘k’, x3, y3, ‘k’);
axis([-4, 4, -15, 15]);

Problem 15

Script file:

%problem 15
figure(15)
x=linspace(-1,1,200);
ya=(x.^2).^(1/3)+ sqrt(1-x.^2);
yb=(x.^2).^(1/3)- sqrt(1-x.^2);
plot(x, ya, ‘k’, x, yb, ‘k’);
axis equal

Problem 16

Script file:

%problem 16
figure(16)
t=[-4:0.005:4];
x= (3.3-0.3*t.^2).*(cos(t));
y=(3.3-0.4*t.^2).*(sin(t));
plot(x,y, ‘k’, ‘LineWidth’, 35)
axis([-2,4,-3,3])

Problem 17

Script file:

%problem 17
figure(17)
th=linspace(0,5*pi,200);
r=th.^0.5;
polar(th, r, ‘k’)
hold on
polar(th, -r, ‘k’)
hold off

Problem 18

Script file:

%problem 18
figure(18)
n=1:100;
th=135.7*n*pi/180;
r=1*n.^0.5;
polar(th, r,’o’)

Problem 19

Script file:

%problem 19
figure(19)
t=(-.75:.01:2.25);
r=(sin(2.*t))./(((cos(t)).^3)+((sin(t)).^3));
x=r.*cos(t);
y=r.*sin(t);
plot(x,y,’k’)
axis([-2,2,-2,2])

Problem 20

Script file:

%problem 20
figure(20)
% ((x^2)/(a^2))+((y^2)/(b^2))=1
a=10;
b=4;
x=[-10:.01:10];
theta=30;
y1=sqrt((1-((x.^2)/(a^2))).*(b^2));
y2=-sqrt((1-((x.^2)/(a^2))).*(b^2));
% The rotated ellipse
x3=(x.*cosd(theta))+(y1.*sind(theta));
y3=-((-x.*sind(theta))+(y1.*cosd(theta)));
y4=-y3;
plot(x,y1,’r’,x,y2,’r’,x3,y3,’–b’,-x3,y4,’–b’)
axis([-15,15,-10,10])

Problem 21

Script file:

%Problem 21
figure(21)
t=[10:10:70];
H1=[9 22 44 63 80 94 97];
H2=(100.8)./(1+(23.*(exp(-0.093.*t))));
plot(t,H1,’o’,t,H2,’r’)
legend(‘Height Data’,’Height Calculated’,’Time’)
xlabel(‘Time’)
ylabel(‘Height’)

Problem 22

Script file:

% Problem 22
figure(22)
t=[0:.01:15];
vc=36.*(1-exp(-t./3));
plot(t,vc)
grid on
xlabel(‘Time’)
ylabel(‘Voltage’)

Problem 23

Script file:

% Problem 23
figure(23)
E0=0.885e-12;
q=2.4e-5;
Q=9.4e-6;
R=.1;
z=[0:.01:.3];
F=((Q.*q.*z)/(2.*E0)).*(1-(z./(sqrt((z.^2)+(R.^2)))));
plot(z,F,’b’);
[A B]=max(F);
fprintf(‘The Maximum of F is %3.2f and the Corresponding Z is %3.2f\n’,A,z(B))

Problem 24

Script file:

% Problem 24
figure(24)
t=[0:.1:5];
x=(52.*t)-(9.*(t.^2));
y=(125-(5.*(t.^2)));
vx=52-(18.*t);
vy=-10.*t;
v=sqrt((vx.^2)+(vy.^2));
[A B]=min(v);
subplot(2,1,1)
plot(x,y,’b’,x(B),y(B),’*’)
xlabel(‘X-Position’)
ylabel(‘Y-Position’)
subplot(2,1,2)
plot(t,v,’k’)
xlabel(‘Time’)
ylabel(‘Velocity’)
fprintf(‘The minimum Velocity is %4.2f and the position of the particle at that time is (%4.2f,%4.2f)\n’,A,x(B),y(B))

Problem 25

Script file:

% Problem 25
figure(25)
t=[0:.01:38.32];
g=9.81;
V0=200;
theta=70;
h=( V0 .* t .* sind(theta) )-( ( g .* (t.^2) ) ./2 );
v=sqrt((V0.^2)-(2.*V0.*g.*t.*(sind(theta)))+((g.^2).*(t.^2)));
tmin=2*(V0.*sind(theta))./g;
Vmin=min(tmin);
subplot(2,1,1)
plot(t,h,’-b’)
xlabel(‘Time’)
ylabel(‘Height’)
legend(‘Time vs Height’)
subplot(2,1,2)
plot(t,v,’-r’)
xlabel(‘Time’)
ylabel(‘Velocity’)
legend(‘Time Vs Velocity’)
fprintf(‘The time it will take for the projectile to hit the ground is %5.2f seconds\n’,Vmin)

Problem 26

Script file:

% Problem 26
figure(26)
t=[0:.01:8];
pt=(8-(4.*(t.^3).*exp(-0.4.*t))+(2.*(t.^2)));
x=(8-(4.*(t.^3).*exp(-0.4.*t))+(2.*(t.^2)));
vt=t.*(exp(-0.4.*t).*t.*(1.6.*t-12)+4);
at=(4.29005.*(t.^3))-(24.1315.*(t.^2))+4;
subplot(3,1,1)
plot(t,x,’r’)
xlabel(‘Time’)
ylabel(‘Position’)
subplot(3,1,2)
plot(t,vt,’b’)
xlabel(‘Time’)
ylabel(‘Velocity’)
subplot(3,1,3)
plot(t,at,’g’)
xlabel(‘Time’)
ylabel(‘Acceleration’)

Problem 27

Script file:

%problem 27
figure(27)
c=3.*10.^8;
h=6.626.*10.^-34;
k=1.38.*10.^-23;
Lambda=[ 0.1 : .001 : 3 ];
lambda=Lambda.*1e-6;
T=[3000 4000 5000];
R1= (2*pi.*h.*(c.^2))./((lambda.^5).*(exp((h.*c)./(k.*T(1).*lambda))-1));
R2= (2*pi.*h.*(c.^2))./((lambda.^5).*(exp((h.*c)./(k.*T(2).*lambda))-1));
R3= (2*pi.*h.*(c.^2))./((lambda.^5).*(exp((h.*c)./(k.*T(3).*lambda))-1));
plot(lambda,R1,’-r’,lambda,R2,‘-g’,lambda,R3,’-k’)
legend(‘T=3000k’,’T=4000k’,’T=5000k’)
xlabel(‘Wavelength (microm)’)
ylabel(‘Spectral Energy Density (W/m^3)’)

Problem 28

Script file:

%problem 28
figure(28)
f=[10:1:50000];
w=2.*pi.*f;
R=2000;
C=0.2e-6;
v0v1=(w.*R.*C)./((1+(w.^2).*(R.^2).*(C.^2)).^(1/2));
semilogx(f,v0v1,’r’)
xlabel(‘Frequency (Hz)’)
ylabel(‘V0/Vi’)

Problem 29

Script file:

%problem 29
figure(29)
R=4;
L=1.3;
V=12;
t1=[0:.01:.5];
it1=(V./R).*(1-exp((-R.*t1)./(L)));
t2=[.5:.01:2];
it2=(exp(-(R.*t2)./L)).*(V./R).*(exp(0.5.*R./L)-1);
plot(t1,it1,’k’,t2,it2,’k’)
xlabel(‘Time’)
ylabel(‘Current’)

Problem 30

Script file:

%problem 30
figure(30)
F = [0 4390 7250 10780 11710 12520 12800 13340 13740 13820 13850 13910 13990 14020 14130];
L=[0.5 .50146 .50226 .50344 .50423 .50577 .50693 .51138 .52006 .52169 .52362 .52614 .53406 .54018 .56466];
r = 0.25;
A0 = 0.5;
L0 = 0.5;
sigmae=(F)./(A0);
epsilone=(L-L0)./(L0);
sigmat=(F.*L)./(A0.*L0);
epsilont=log(L./L0);
subplot(2,1,1)
plot(F,sigmae,’c’,F,sigmat,’–b’)
xlabel(‘Force (lb)’)
ylabel(‘Length (in)’)
legend(‘Engineering Stress’,’True Stress’)
subplot(2,1,2)
plot(F,epsilone,’g’,F,epsilont,’–r’)
xlabel(‘Force (lb)’)
ylabel(‘Length (in)’)
legend(‘Engineering Strain’,’True Strain’)

Problem 31

Script file:

%problem 31
figure(31)
c=300e6;
L=2;
v=[0:100:300e6];
delta=L.*(1-(sqrt(1-((v.^2)./(c.^2)))));
plot(v,delta,’r’)
xlabel(‘Velocity’)
ylabel(‘Delta’)
semilogx(v,delta,’k’)
xlabel(‘Velocity’)
ylabel(‘Delta’)
loglog(v,delta,’b’)
xlabel(‘Velocity’)
ylabel(‘Delta’)

Problem 32

Script file:

%problem 32
figure(32)
t=[0:.01:4];
xt=4.219.*(exp(-1.58.*t)-exp(-6.32.*t));
vt=(26.67.*(exp(-6.32.*t)))-(6.67.*(exp(-1.58.*t)));
subplot(2,1,1)
plot(t,xt,’r’)
xlabel(‘Time’)
ylabel(‘Position’)
subplot(2,1,2)
plot(t,vt,’b’)
xlabel(‘Time’)
ylabel(‘Velocity’)

Problem 33

Script file:

%problem 33
figure(33)
R=0.08206;
a=3.592;
b=0.04267;
n=1;
T=297;
V=[0.065:.001:1];
PI=(n).*(R).*(T)./(V);
PVdW=((n.*R.*T)./(V-(n.*b)))-(((n.^2).*a)./(V.^2));
plot(V,PI,’–r’,V,PVdW,’b’)
title(‘Gas Isotherms’)
xlabel(‘Volume’)
ylabel(‘Pressure’)
legend(‘Ideal Gas Law’,’Van der Waals’)

Problem 34

Script file:

%problem 34
figure(34)
f1=130;
f2=120;
t=[0:.001:.3];
y1=cos(2.*pi.*f1.*t);
y2=cos(2.*pi.*f2.*t);
y=2.*cos(2.*pi.*((f1+f2)./2).*t).*cos(2.*pi.*((f1-f2)./2).*t);
plot(t,y,’k’)
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)

Problem 35

Script file:

%problem 35
figure(35)
I0=10e-14;
vS=1.5;
R=1200;
ktq=0.030;
vD=[0:.01:1.5];
iD1=I0.*(exp((vD./ktq))-1);
iD2=(vS-vD)./R;
intersection = find(iD1-iD2<eps,1);
px=iD2(intersection);
py=iD2(intersection);
plot(vD,iD1,’r’,vD,iD2,’r’,px,py,’o’)
axis([0,1.5,-.02,0.02])

Problem 36

Script file:

%problem 36
figure(36)
lambda=4.80e-7;
a=0.025e-3;
d=0.09e-3;
L=100;
y=[-4:.01:4];
R=sqrt(L.^2+y.^2);
alpha=(pi.*a)./(lambda).*(y./R);
beta=(pi.*d)./(lambda).*(y./R);
I=(cos(beta).^2).*((sin(alpha)./alpha).^2);
plot(y,I,’k’)
xlabel(‘Distance (cm)’)
ylabel(‘Relative Intensity’)

Problem 37

Script file:

%problem 37
figure(37)
x1=[0:.01:8];
Vx1=400-200.*x1;
Mx1=-100.*(x1.^2)+400.*x1;
x2=[8:.01:12];
Vx2=-1200.*(x2./x2);
Mx2=-1200.*x2+6400;
x3=[12:.01:20];
Vx3=-250.*x3+5000;
Mx3=(-125.*((x3-12).^2))+(2000.*x3)-32000;
subplot(2,1,1)
plot(x1,Vx1,’r’,x2,Vx2,’r’,x3,Vx3,’r’)
legend(‘Shear Force’)
xlabel(‘Distance ft’)
ylabel(‘Shear Force’)
subplot(2,1,2)
plot(x1,Mx1,’b’,x2,Mx2,’b’,x3,Mx3,’b’)
legend(‘Bending Moment’)
xlabel(‘Distance ft’)
ylabel(‘Bending Moment’)

Problem 38

Script file:

%problem 38
figure(38)
Q=300;
D=[100:.01:2000];
L0=[5 10 20];
Lc1=(L0(1))./(1+(2.5.*(D.^(2/3)))./(sqrt(Q)));
Lc2=(L0(2))./(1+(2.5.*(D.^(2/3)))./(sqrt(Q)));
Lc3=(L0(3))./(1+(2.5.*(D.^(2/3)))./(sqrt(Q)));
subplot(3,1,1)
plot(D,Lc1,’r’)
xlabel(‘X Side’)
ylabel(‘Y Side’)
subplot(3,1,2)
plot(D,Lc2,’r’)
xlabel(‘X Side’)
ylabel(‘Y Side’)
subplot(3,1,3)
plot(D,Lc3,’r’)
xlabel(‘X Side’)
ylabel(‘Y Side’)

Problem 39

Script file:

%problem 39
figure(39)
t=0.12;
p=0.4;
m=0.04;
c=1.5;
x1=[0:.01:p.*c];
x2=[p.*c:.01:c];
yt1=5.*t.*c.*((0.2969).*sqrt(x1./c)-0.126.*(x1./c)-0.3516.*((x1./c).^2)+0.2843.*((x1./c).^3)-0.1015.*((x1./c).^4));
yt2=5.*t.*c.*((0.2969).*sqrt(x2./c)-0.126.*(x2./c)-0.3516.*((x2./c).^2)+0.2843.*((x2./c).^3)-0.1015.*((x2./c).^4));
theta1=atan((2.*m)./(p.^2).*(p-(x1./c)));
theta2=atan((2.*m)./((1-p.^2)).*(p-(x2./c)));
yc1=(m.*(x1./(p.^2)).*((2.*p)-(x1./c)));
yc2=(m.*(c-x2)./((1-p).^2).*(1+(x2./c)-2.*p));
xU1=x1-yt1.*sind(theta1);
xL1=x1+yt1.*sind(theta1);
xU2=x2-yt2.*sind(theta2);
xL2=x2+yt2.*sind(theta2);
yU1=yc1+(yt1.*(cosd(theta1)));
yL1=yc1-(yt1.*(cosd(theta1)));
yU2=yc2+(yt2.*(cosd(theta2)));
yL2=yc2-(yt2.*(cosd(theta2)));
plot(xU1,yU1,’k’,xU2,yU2,’k’,xL1,yL1,’k’,xL2,yL2,’k’)
axis([0,1.5,-.2,.2])
xlabel(‘x (m)’)
ylabel(‘y (m)’)

Problem 40

Script file:

%problem 40
figure(40)
x=[0:.01:4.5];
y=sin(x).^2;
y2=(x.^2)-(((2.^3).*(x.^4))./(4.*3.*2.*1));
y3=(x.^2)-(((2.^3).*(x.^4))./(4.*3.*2.*1))+(((2.^5).*(x.^6))./(6.*5.*4.3.*2.*1));
y5=(x.^2)-(((2.^3).*(x.^4))./(4.*3.*2.*1))+(((2.^5).*(x.^6))./(6.*5.*4.3.*2.*1))-(((2.^5).*(x.^6))./(6.*5.*4.3.*2.*1))+(((2.^7).*(x.^8))./(8.*7.*6.*5.*4.*3.*2.*1));
plot(x,y,’k’,x,y2,’–r’,x,y3,’–b’,x,y5,’–g’)
legend(‘Sin^2(x)’,’Two Terms’,’Three Terms’,’Five Terms’)
xlabel(‘X’)
ylabel(‘sin^2(x)’)
axis([-1,5,-.2,1.5])