Recitation Problems  for Matlab Week 1 and Week 2

Recitation Problems  for Matlab Week 1 and Week 2

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Poojan Patel MATLAB 1/25/2012 Recitation Problems for Matlab Week 1 Problem #1 Practice exercises 2.3 1) >> 6/6+5 ans = 6 2) >> 2*6^2 ans = 72 3) >> (3+5)*2 ans = 16 4) >> 3+5*2 ans = 13 5) >> 4*3/2*8 ans = 48 6) >> 3-2/4+6^2 ans = 38.5000 7) >> 2^3^4 ans =
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Poojan Patel MATLAB 1/25/2012 4096 8) >> 2^(3^4) ans = 2.4179e+024 9) >> 3^5+2 ans = 245 10) >> 3^(5+2) ans = 2187 11) >> (5+3)/(9-1) ans = 1 12) >> 2^3-(4)/(5+3) ans = 7.5000 13) >> (5^(2+1))/(4-1) ans = 41.6667 14) >> 2*(10)/(3) ans = 6.6667 15) >> [5+6*(7/3)-2^2]/[(2/3)*(3/3*6)]
Background image of page 2
Poojan Patel MATLAB 1/25/2012 ans = 3.7500 Practice Exercises 2.4 1) >> a= [2.3 5.8 9] a = 2.3000 5.8000 9.0000 2) >> sin(a) ans = 0.7457 -0.4646 0.4121 3) >> a+3 ans = 5.3000 8.8000 12.0000 4) >> b= [5.2 3.14 2] b = 5.2000 3.1400 2.0000 5) >> a+b ans = 7.5000 8.9400 11.0000 6) >> a.*b ans = 11.9600 18.2120 18.0000 7) >> a.^2 ans =
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Poojan Patel MATLAB 1/25/2012 5.2900 33.6400 81.0000 8) >> c= [0 1 2 3 4 5 6 7 8 9 10] c = 0 1 2 3 4 5 6 7 8 9 10 9) >> c= [0 2 4 6 8 10] c = 0 2 4 6 8 10 10) >> linspace(10, 20, 6) ans = 10 12 14 16 18 20 11) >> logspace(1, 2, 5) ans = 10.0000 17.7828 31.6228 56.2341 100.0000 Problem #2 >> a= [1 2 4 5] a = 1 2 4 5 >> b= [5 4 2 1] b = 5 4 2 1 >> a+10 ans =
Background image of page 4
Poojan Patel MATLAB 1/25/2012 11 12 14 15 >> a*10 ans = 10 20 40 50 >> a+b ans = 6 6 6 6 >> a.*b, ans = 5 8 8 5 >> a./b, ans = 0.2000 0.5000 2.0000 5.0000 >> a+1./b, ans = 1.2000 2.2500 4.5000 6.0000 >> 1./a+b ans = 6.0000 4.5000 2.2500 1.2000 >> a.^2, ans = 1 4 16 25 >> a+b.^2,
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Poojan Patel MATLAB 1/25/2012 ans = 26 18 8 6 >> a.^2./a, ans = 1 2 4 5 >> a.^2./b, ans = 0.2000 1.0000 8.0000 25.0000 >> (a.^2)./b, ans = 0.2000 1.0000 8.0000 25.0000 >> a.^(2./b), ans = 1.0000 1.4142 4.0000 25.0000 >> a./b.^2, ans = 0.0400 0.1250 1.0000 5.0000 >> (a./b).^2 ans = 0.0400 0.2500 4.0000 25.0000 After looking at and using the following operations: + */ ^, I can conclude that each of the operations are important in their own way and serve a different purpose. No one operation has precedence over another because they all serve a very important purpose in matlab.
Background image of page 6
Poojan Patel MATLAB 1/25/2012 Problem # 3 Code examples pp. 32-40 week-1 lecture notes >> x= 0: 0.2: 1 x = 0 0.2000 0.4000 0.6000 0.8000 1.0000 >> x= linspace(0,1,6) x = 0 0.2000 0.4000 0.6000 0.8000 1.0000 >> x= 0: 0.3: 1 x = 0 0.3000 0.6000 0.9000 >> x= 0: 0.4: 1 x = 0 0.4000 0.8000 >> x= 0: 0.7: 1 x = 0 0.7000 >> x= [2, 5, -6, 10, 3, 4]; >> double x[6] ans = 120 91 54 93 >> x= [2, 5, -6, 10, 3, 4] x =
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Poojan Patel MATLAB 1/25/2012 2 5 -6 10 3 4 >> length(x) ans = 6 >> x(1) ans = 2 >> x(3) ans = -6 >> x(end) ans = 4 >> x(end-3:end) ans = -6 10 3 4 >> x(3:5) ans = -6 10 3 >> x(1:3:end) ans = 2 10 >> x(1:2:end)
Background image of page 8
Poojan Patel MATLAB 1/25/2012
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

Recitation Problems  for Matlab Week 1 and Week 2

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online