MAT 275 MATLAB LAB 2 Alejandro Carranza

MAT 275 MATLAB LAB 2 Alejandro Carranza

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
Image of page 1

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
Image of page 2
Image of page 3

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern