Can someone explain to me how this function works?
Show older comments
function finElemNext = nextTemps( finElem )
% This function will create a new fin element array by averaging the
% temperatures surrounding each element location
% uses finElemNext = nextTemps( finElem )
global maxDelta
maxDelta=0;
newFin=zeros(numRows,numCols);
for i = 2 : (numRows - 1)
for j = 2 : (numCols - 1)
t_original=finElem(i,j);
if t_original~=steamTemp
t_row_above=finElem(i-1,j);
t_row_below=finElem(i+1,j);
t_col_left=finElem(i,j-1);
t_col_right=finElem(i,j+1);
newFin(i,j)=mean([t_original,t_row_above,t_row_below,t_col_left,t_col_right]);
delta=finElem(i,j)-newFin(i,j);
if delta>maxDelta
maxDelta=delta;
end
else
newFin(i,j)=finElem(i,j);
end
end
end
finElemNext=setupFin(newFin);
end
I just need to be able to explain how this program calculates the data for this function. Thanks in advance :)
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!