SUNY Geneseo Department of Computer Science


Introduction to “For” Loops

Monday, March 3

CSci 120, Spring 2014
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture

Misc

Edinburgh engineering has reorganized its web site

Exam Questions, Solutions, etc?

Question 4 (matrices, copying A to result wherever A > B)?

    function C = pick( A, B )
        mask = A > B;
        C = mask .* A;
    end

>> A = [ 4 6 9; 8 2 4]
    A =
        4     6     9
        8     2     4
>> B = [ 3 8 9; 10 1 3]
    B =
        3     8     9
        10     1     3
>> pick(A,B)
    ans =
        4     0     0
        0     2     4

Questions?

For Loops Lesson

Handout


Next Lecture