MAT 275 MATLAB LAB 2 Alejandro Carranza

# MAT 275 MATLAB LAB 2 Alejandro Carranza

• Lab Report
• 3
• 100% (6) 6 out of 6 people found this document helpful

This preview shows page 1 - 3 out of 3 pages.

MAT 275 MATLAB LAB 2 Alejandro Carranza Monday 9:40 AM Javier Baez %%Exercise 1 %Part a %vectors A, B, b, c, and d >>A = [1 4 2; 2 5 8; 3 6 9]; >>B = [1 2 3; 4 5 6; 7 8 9]; >>b = [4; 23; 27]; >>c = [4 3 2]; >>d = [1; 2; 3]; %multilpy using stantard linear multiplication >>A*B ans = 31 38 45 78 93 108 90 108 126 >>B*A ans = 14 32 45 32 77 102 50 122 159 >>c*B ans = 30 39 48 >>A*d ans = 15 36 42 %Part b %4*3 matrix C=[A B] and 4*3 matrix D=[B; c] >>C = [A B] C = 1 4 2 1 2 3 2 5 8 4 5 6 3 6 9 7 8 9 >>D = [B; c] D = 1 2 3 4 5 6 7 8 9 4 3 2 %Part c %Find x in Ax=b using backlash command >>x = A\b x = 2.0000 -1.0000 3.0000 %Part d %Replace A(2,3) with 0 >>A(2, 3)=[0] A = 1 4 2 2 5 0 3 6 9 %Part e

Subscribe to view the full document.

%Extract 3rd row of matrix A >>A(3,:) ans = 3 6 9 %Part f %Delete 3rd row of matrix A >>A(3,:)=[] A = 1 4 2 2 5 0 %%Exercise 2 %Part a % function [ S ] = geomsum(a,r,n) %geometric sum of series a+ar+ar^2+ar^3+... S=0; %initialize sum for k=0:n-1 %from 0 to n-1 S=S+a*r^k; %sum of series of k end end >>geomsum(3,1/2,10) ans = 5.9941

### 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