If the following script was run in MATLAB, what would be the value of Sum? A = [1, 2, 3; 4, 5, 6; 7, 8, 9] for r = 1:3 Sum = 0; for c = 1:2 Sum= Sum + A(r,c); end end 0 8 ? 45 ? 15 ? 27
Added by Diane W.
Close
Step 1
Step 1: The script iterates through the matrix A, adding the values of each row to the variable Sum. Show more…
Show all steps
Your feedback will help us improve your experience
Aman Gupta and 54 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Question 4 Suppose that we were to perform a trace of the algorithm that computes the sum of the entries of a matrix (algorithm is provided below) on the matrix. What would the value be for the "sum" variable immediately after the 2,j pass of the loop? 1. Input: A matrix A with integer entries denoted by aij, for integers m and n. 2. Initialize: sum := 0 3. For i starting at 1 up through m: For j starting at 1 up through n: sum := sum + aij (This updates the sum to be the old sum plus the current entry) Output: sum
Aman G.
QUESTION Matrix Entry Value Choose one • 4 points Find the value at entry m34 in M (1 1 3 5 5 1 6 2 7 8 9 2 3 5 9 10) m34=9 m34=-2 m34=3+4=7 QUESTION GROUP QUESTION Transpose of a non-squared Matrix Choose one • 4 points Find the transpose of A= (1 1 3 5 5 -1 6 2), At At=(5 1 -1 1 6 3 2 5) At= (5 -1 6 2 1 1 3 5) At= (1 5 1 -1 3 6 5 2) QUESTION Trace of a Squared Matrix Choose one • 4 points Find the trace of matrix A= (1 1 3 5 5 -1 6 2 7 8 9 -2 3 5 9 10) Trace(A)=16 Trace(A)=10 Trace(A)=19 QUESTION Matrix-Vector Multiplication Choose one • 4 points Let A= (2 1 0 0 3 1 3 1 0) and v=(1 2 1), calculate A·v A·v= (4 7 5) A·v=(4 7 5) A·v= (3 8 4) QUESTION System of Linear equations and Augmented Matrix. Choose one • 4 points Write the augmented matrix of the following system of linear equations {x+3y+z=4 2x-y+2z=1 3x-y+2z=3} (1 3 1 4 2 -1 2 1 3 -1 2 3) (1 3 1 2 -1 2 3 -1 2) (1 3 1 -4 2 -1 2 -1 3 -1 2 -3)
Madhur L.
Sarah G.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD