This preview shows pages 1–3. Sign up to view the full content.
HOMEWORK #11
Due: November 12 – 18
1.
Reading Assignment
Complete the assigned reading posted on the Course Schedule on the ENGR 126 Blackboard
homepage.
2.
Debugging Code Part II
This section to be completed individually.
Identify THREE errors in the code below using the table after the code.
Clearly indicate the line
number of the error, describe the error and how it could be fixed.
Each error counts as one, even if
there are multiple errors on the same line.
Line
Number
MATLAB Code
1
function [new_temp]=total_plate(temp_matrix)
2
% This function recalculates the temperature of every position on a heating plate
3
% by averaging the surrounding values.
4
% The input is temp_matrix, the temperature matrix (degrees Celsius)
5
% The output is new_temp, the updated temperature matrix (degrees Celsius)
6
7
%  Input Section 
8
[n,m] = size(temp_matrix);
% Determine the size of the matrix
9
10
%  Calculation Section 
11
for x = 1:m
% Loops through rows of matrix
12
while y = = 1:n
% Loops through columns of matrix
13
if r == 1  r == n  c == 1  c == m
% Calculates edges and corners
14
new_temp(x,y) = temperature_update_corner(temp_matrix,n,m);
15
else
% Calculates center section
16
new_temp(x,y) = temperature_update_middle(temp_matrix,x,y);
17
end
18
end
19
end
Line number
What is the error?
How could it be fixed?
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentDeliverables: A hard copy printout of the three errors identified above.
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '08
 Oakes

Click to edit the document details