Recitation Problems &Acirc;&nbsp;for Matlab Week 1 and Week 2

Recitation Problems Â for Matlab Week 1 and Week 2

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

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 =

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

View Full Document
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)]
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 =

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

View Full Document
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 =
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,

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

View Full Document
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.
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 =

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

View Full Document
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)
Poojan Patel MATLAB 1/25/2012

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern