Science:Math Exam Resources/Courses/MATH152/April 2013/Question A 28
• QA 1 • QA 2 • QA 3 • QA 4 • QA 5 • QA 6 • QA 7 • QA 8 • QA 9 • QA 10 • QA 11 • QA 12 • QA 13 • QA 14 • QA 15 • QA 16 • QA 17 • QA 18 • QA 19 • QA 20 • QA 21 • QA 22 • QA 23 • QA 24 • QA 25 • QA 26 • QA 27 • QA 28 • QA 29 • QA 30 • QB 1(a) • QB 1(b) • QB 1(c) • QB 1(d) • QB 2(a) • QB 2(b) • QB 2(c) • QB 2(d) • QB 3(a) • QB 3(b) • QB 3(c) • QB 4(a) • QB 4(b) • QB 4(c) • QB 5(a) • QB 5(b) • QB 5(c) • QB 6(a) • QB 6(b) • QB 6(c) •
Question A 28 |
---|
Suppose we run the following MATLAB code A=ones(4,4); for j=1:4; A(j,:)=j*A(j,:); end; Specify the output if you now type: >> A(2,4) |
Make sure you understand the problem fully: What is the question asking you to do? Are there specific conditions or constraints that you should take note of? How will you know if your answer is correct from your work only? Can you rephrase the question in your own words in a way that makes sense to you? |
If you are stuck, check the hints below. Read the first one and consider it for a while. Does it give you a new idea on how to approach the problem? If so, try it! If after a while you are still stuck, go for the next hint. |
Hint 1 |
---|
The first line creates a four by four matrix of ones. |
Hint 2 |
---|
The key is the line within the for loop. Notice that A(j,:) is the jth row and that it is replaced by a multiple of itself, namely its row index. We are interested in the element in the second row and fourth column. |
Checking a solution serves two purposes: helping you if, after having used all the hints, you still are stuck on the problem; or if you have solved the problem and would like to check your work.
|
Solution |
---|
Found a typo? Is this solution unclear? Let us know here.
Please rate my easiness! It's quick and helps everyone guide their studies. The hints should explain most of what's going on. Here is the output. For A=ones(4,4) we get
Then after the loop executes for j=1, we get
(which is the same as the original A). After j=2, the matrix looks like
Finally, the code A(2,4) looks in row two column 4 for the value. The answer is 2. |