Finite Temperature Variation - Heat Transfer
1 view (last 30 days)
Show older comments
I am having trouble generating a coefficient matrix of different node types. Please take a look at my code and tell me where was my mistakes. My geometry cuts off at the top. Meaning it is half a node along the top.
%Under slant RIGHT SIDE
for i= (.6*n^2)+1:(n*n)
if (mod(i,n)==1+s);
A(i,i-1)=1;
A(i,i+1)=1;
A(i,i)=((h*sqrt(2))/k)-2;
g(i)=((h*sqrt(2))/k)*Tinf;
%BOTTOMROW!!!
% Last line
elseif (mod(i,n)==0)
A(i,i-1)= 1;
A(i,i)=-3;
A(i,i-n)=1;
A(i,i+n)=1;
g(i)=0;
s=s+1;
%last column
elseif (i==((n*n)-.4*n)+1)
A(i,i-1)= 1;
A(i,i)=-3;
A(i,i-n)=1;
A(i,i+n)=1;
g(i)=0;
%bottom right corner(n^2)
elseif (i==n*n)
A(i,i-1)= 1;
A(i,i)=-2;
A(i,i-n)=1;
g(i)=0;
%Right side under slant %non-gen in between gen and slant
else
A(i,i+1)=1;
A(i,i-n)=1;
A(i,i+n)=1;
A(i,i-1)=1;
A(i,i)=-4;
g(i)=0;
end
end
T=A\g';
T( ~any(T,2), : ) = []; %rows
a = T == 10;
T(a) = NaN;
T2= abs(real(T));
Temp = vec2mat(T2,n);
Temp1=diag(((.6*n^2)+1),0);
surf(Temp)
0 Comments
Answers (0)
See Also
Categories
Find more on Thermal Analysis 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!