1 / 4

COMP 116: Introduction to Scientific Programming

COMP 116: Introduction to Scientific Programming . Lecture 18: Nested loops and review. Quiz 4 function. Nested loops: what does this code do?. % Assume A and B are pre-assigned % matrices and of the same size C=zeros(size(A)); for i =1:size(A,1) for j=1:size(A,2)

thane
Download Presentation

COMP 116: Introduction to Scientific Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP 116: Introduction to Scientific Programming Lecture 18: Nested loops and review

  2. Quiz 4 function

  3. Nested loops: what does this code do? % Assume A and B are pre-assigned % matrices and of the same size C=zeros(size(A)); for i=1:size(A,1) for j=1:size(A,2) C(i,j)=A(i,j)*B(i,j) end end

  4. Exercise • Write a function that • given two matrices • returns their product (matrix multiplication not element-wise multiplication) • Use nested for loops • For the first version of the code you can assume that the input matrices are the right size • For the final version, make no such assumption

More Related