12
Fall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition, Chapter 4 Page 123, Problem 2 Description % code format short g F=100000; N=5:1:10; r=4.35/100; P=F*(r/12)./((1+r/12).^(12*N)-1); T=[N' P']; disp(' Number of years Montly Deposit') Number of years Montly Deposit disp(T) 5 1495 6 1218 7 1020.6 8 872.78 9 758.13 10 666.67 Page 124, Problem 4 Description % code clear r2=12:4:28; r1=0.7*r2; V=1/4*pi^2*(r1+r2).*(r2-r1).^2; S=pi^2*(r2.^2-r1.^2); T=[r2' r1' V' S']; disp(' r2 r1 V S') r2 r1 V S disp(T) 12 8.4 652.34 724.82 16 11.2 1546.3 1288.6 20 14 3020.1 2013.4 24 16.8 5218.7 2899.3

Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

  • Upload
    others

  • View
    23

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Fall 2017 MATLAB Assignment C: OUTPUTS

Math 152-5xx, Team A, #0 Your Name, UIN 123456789

Gilat 5th Edition, Chapter 4

Page 123, Problem 2

Description

% codeformat short gF=100000;N=5:1:10;r=4.35/100;P=F*(r/12)./((1+r/12).^(12*N)-1);T=[N' P'];disp(' Number of years Montly Deposit')

Number of years  Montly Deposit

disp(T)

            5         1495            6         1218            7       1020.6            8       872.78            9       758.13           10       666.67

Page 124, Problem 4

Description

% codeclearr2=12:4:28;r1=0.7*r2;V=1/4*pi^2*(r1+r2).*(r2-r1).^2;S=pi^2*(r2.^2-r1.^2);T=[r2' r1' V' S'];disp(' r2 r1 V S')

           r2          r1          V            S

disp(T)

           12          8.4       652.34       724.82           16         11.2       1546.3       1288.6           20           14       3020.1       2013.4           24         16.8       5218.7       2899.3

Page 2: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

           28         19.6       8287.2       3946.3

Page 126, Problem 13

Description

% codea=5:0.25:100;b=2*(sqrt(55^2-(a/2).^2));S=(a-2*4).*(b-2*10);[maxS,ind]=max(S);maxa=a(ind);maxb=b(ind);fprintf('The area of the lagest rectanlge is %.2f when a is %.2f and b is %.2f.\n', maxS, maxa, maxb)

The area of the lagest rectanlge is 4051.88 when a is 74.50 and b is 80.93.

Page 127, Problem 15

Description

% codeh=900; H=70;x=50:0.5:1500;al=atan((h-H)./x);be=atan(h./x);theta=be-al;[maxth,i]=max(theta);fprintf('The largest value of theta %.3f when x is %.2f', maxth, x(i))

The largest value of theta 0.040 when x is 864.50

Page 132, Problem 28

Description

% code[T,v]=meshgrid(40:-10:-40, 10:10:60);Twc=35.74+0.6215*T-35.75*v.^0.16+0.4275*T.*v.^(0.16);ta=round(Twc);Table=[v(:,1) ta];disp(' Temperatur(F)')

                             Temperatur(F)

disp(' 40 30 20 10 0 -10 -20 -30 -40')

          40    30    20    10     0   -10   -20   -30   -40

disp(' Speed')

  Speed

Page 3: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

disp(' (mi/h)')

  (mi/h)

disp(Table)

    10    34    21     9    -4   -16   -28   -41   -53   -66    20    30    17     4    -9   -22   -35   -48   -61   -74    30    28    15     1   -12   -26   -39   -53   -67   -80    40    27    13    -1   -15   -29   -43   -57   -71   -84    50    26    12    -3   -17   -31   -45   -60   -74   -88    60    25    10    -4   -19   -33   -48   -62   -76   -91

Gilat 5th Edition, Chapter 5

Page 165, Problem 6

Description

% codefigurefplot(@(x) (sin(2.*x)+cos(5.*x).^2).*exp(-0.2.*x),[-6,6])

Page 165, Problem 8

Page 4: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Description

% codefigurex=@(t) 4.2+cos(t)*7.5;y=@(t) 2.7+sin(t)*7.5;fplot(x,y,[0,2*pi])title('circle')xlabel('x'); ylabel('y');axis equalxlim([-5,13]);ylim([-7,12]);

Page 167, Problem 18

Description

% codeP=@(t) 11.55./(1+18.7.*exp(-0.0193.*(t-1850)));td=[1850 1910 1950 1980 2000 2010];Pd=[1.3 1.75 3 4.4 6 6.8];figurefplot(P,[1900,2180]);hold onplot(td,Pd,'ro');title('Population')legend('Model','Real')xlim([1800,2200])xlabel('Years'); ylabel('Population(billions)')

Page 5: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

hold off

Page 168, Problem 22

Description

% codet=0: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);[minv,ind]=min(v);figuresubplot(1,2,1); plot(x,y,x(ind),y(ind),'r*')xlabel('x(m)'); ylabel('y(m)');subplot(1,2,2); plot(t,v)xlabel('t(s)'); ylabel('v(m/s)')

Page 6: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

 

Page 168, Problem 24

Description

% codesyms tx=(-3+4*t)*exp(-0.4*t);v=diff(x);a=diff(v);figuresubplot(1,3,1); fplot(x,[0,20])xlabel('t(s)'); ylabel('x(ft)');subplot(1,3,2); fplot(v,[0,20]);xlabel('t(s)'); ylabel('v(ft/s)');subplot(1,3,3); fplot(a,[0,20]);xlabel('t(s)'); ylabel('a(ft/s^2)');

Page 7: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Gilat 5th Edition, Chapter 10

Page 341, Problem 1

Description

% codefiguret=0:0.1:30;x=((t-15)/100+1).*sin(3*t);y=((t-15)/100+1).*cos(0.8*t);z=0.4*t.^(3/2);plot3(x,y,z)

Page 8: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Page 342, Problem 5

Description

% codefigure[x,y]=meshgrid(-2:0.05:2, -2:0.05:2);z=0.5*x.^2+0.5*y.^2;surf(x,y,z)title('Surface')xlabel('x'); ylabel('y'); zlabel('z');

Page 9: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Page 342, Problem 7

Description

% codefigure[x,y]=meshgrid(linspace(-2*pi,2*pi,50),linspace(-pi,pi,30));z=cos(x).*cos(sqrt(x.^2+y.^2).*exp(-abs(0.2*x)));surf(x,y,z)title('Surface')xlabel('x'); ylabel('y'); zlabel('z');

Page 10: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

  

Page 342, Problem 8

Description

% codeclear[th,r]=meshgrid(linspace(0,2*pi,30), linspace(0,2,30));x1=r.*cos(th); y1=r.*sin(th); z1=4*r;figure surf(x1,y1,z1)hold on[theta,phi]=meshgrid(linspace(0,2*pi,30), linspace(0,pi/2,30));x2=2.*cos(theta).*sin(phi); y2=2.*sin(theta).*sin(phi); z2=8+2.*cos(phi);surf(x2,y2,z2)title('ice cream cone')xlabel('x'); ylabel('y'); zlabel('z');hold off

Page 11: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

Page 346, Problem 21

Description

% codeclear; close; v0=20; theta=30; alpha=25; g=9.81;vx=v0*sind(theta)*cosd(alpha); vy=v0*sind(theta)*sind(alpha);vz=linspace(0,0,5);%define vz for each bouncefor i=1:5 vz(i)=(0.8)^(i-1)*v0*cosd(theta);end%define the time interval for bouncestb=linspace(0,0,6);for k=2:6 tb(k)=tb(k-1)+2*vz(k-1)/g;endX=linspace(0,0,100);Y=X; Z=X;for j=1:5 t=linspace(tb(j),tb(j+1),20); X((j-1)*20+1:j*20)=vx*t; Y((j-1)*20+1:j*20)=vy*t; tz=t-tb(j); Z((j-1)*20+1:j*20)=vz(j)*tz-1/2*g*tz.^2;end

Page 12: Gilat 5th Edition, Chapter 4 Fall 2017 MATLAB …rlan/math152_F2017/M152C.pdfFall 2017 MATLAB Assignment C: OUTPUTS Math 152-5xx, Team A, #0 Your Name, UIN 123456789 Gilat 5th Edition,

plot3(X,Y,Z)grid onxlabel('x(m)'); ylabel('y(m)'); zlabel('z(m)');  title('Bounce Trajectory')