{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw11problem2

# hw11problem2 - end end end Line 11 Error the index...

This preview shows page 1. Sign up to view the full content.

function [new_temp]=total_plate(temp_matrix) % This function recalculates the temperature of every position on a heating plate % by averaging the surrounding values. % The input is temp_matrix, the temperature matrix (degrees Celsius) % The output is new_temp, the updated temperature matrix (degrees Celsius) % ---- Input Section ---- [n,m] = size(temp_matrix); % Determine the size of the matrix % ---- Calculation Section ---- for x = 1:m % Loops through rows of matrix while y = = 1:n % Loops through columns of matrix if r == 1 | r == n | c == 1 | c == m % Calculates edges and corners new_temp(x,y) = temperature_update_corner(temp_matrix,n,m); else % Calculates center section new_temp(x,y) = temperature_update_middle(temp_matrix,x,y);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end end end % Line #: 11 % Error: the index references the number of columns rather than number of rows % Fix: change x = 1:n. % Line #: 12 % Error: the index references the number of rows rather than number of columns % Fix: change x = 1:m. % Line #: 12 % Error: have while loop rather than a for loop % Fix: change while to for y = 1:m. % Fix2: in line 18 add a n=n+1 counter and in line 19 add a n=1 to reset % while loop counter. % Line #: 13 % Error: r and c are never defined % Fix: change r to x and c to y. % Line #: 14 % Error: the function call only calls lower right corner % Fix: change to temperature_update_corner(temp_matrix,x,y)...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online