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

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

View Full Document Right Arrow Icon
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);
Background image of page 1
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

This note was uploaded on 02/12/2012 for the course ENGR 126 taught by Professor Oakes during the Fall '08 term at Purdue University-West Lafayette.

Ask a homework question - tutors are online