in Wire Problemm 3 of 4 A thin wire with a uniform crosssect

in Wire Problemm 3 of 4 A thin wire with a uniform cross-section will radiate heat from its sides according to Newtonian Cooling -that is, the rate of loss of heat is proportional to the difference in temperature between the object and its surroundings. If the temperature at every point in the wire remains constant, then it satisfies the second-order ODE d T where k is the thermal diffusivity, h is the thermal conductivity of the interface be- tween the object and the environment, and Te is the temperature of the environ- We can approximate the second derivative using a \"central difference formula If we apply this to a series of points in the wire, we can write down a series of equations of the form N+1 Suppose that we require that T(0) = 0 and T(1) 0, That is, the temperature at both ends is held at 0° C. We can let d = 1/N, and this allows us to write down the matrix equation Ti T2 Ts hT. hTe hT. hT. hT. hT. hT. where a = h + 2kN2 and b =-kN2. Your task is to write a MATLAB function that will do the following Take in N, k, h, and Te as input variables, . Generate the relevant matrices and/or vectors (see below) Solve the system (using chosen approach, see below), and Plot the resulting solution T against position r

Solution

N = input(\'enter the value for N = \');
k = input(\'enter the value for k = \');
h = input(\'enter the value for h = \');
Te = input(\'enter the value for Te = \');
T_e = Te*h*ones(N-1,1);
a = h+2*k*N^2;
b = -k*N^2;
A = zeros(N-1,N-1);

% Option 1
for i=1:N-1
A(i,i) = a;
if i~=N-1
A(i,i+1) = b;
end
if i~=1
A(i,i-1) = b;
end
end

T = inv(A)*T_e;
figure
plot(T)

% Option 2

r = T_e;

D=A;d=r;n = N-1;
%-----------------------------------------------------------------
%create upper triangular matrix
s=0;
for j=1:n-1
if A(j,j)==0
k=j;
for k=k+1:n
if A(k,j)==0
continue
end
break
end
B=A(j,:); C=r(j);
A(j,:)=A(k,:); r(j)=r(k);
A(k,:)=B; r(k)=C;
end
for i=1+s:n-1
L=A(i+1,j)/A(j,j);
A(i+1,:)=A(i+1,:)-L*A(j,:);
r(i+1)=r(i+1)-L*r(j);
end
s=s+1;
end

%Solution of equations
x(n)=r(n)/A(n,n);
for i=n-1:-1:1
sum=0;
for j=i+1:n
sum=sum+A(i,j)*x(j);
end
x(i)=(1/A(i,i))*(r(i)-sum);
end
  
figure
plot(x)

 in Wire Problemm 3 of 4 A thin wire with a uniform cross-section will radiate heat from its sides according to Newtonian Cooling -that is, the rate of loss of
 in Wire Problemm 3 of 4 A thin wire with a uniform cross-section will radiate heat from its sides according to Newtonian Cooling -that is, the rate of loss of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site