help plotting at x=0 dt/dx=0

2 vues (au cours des 30 derniers jours)
Nataly Almasri
Nataly Almasri le 3 Oct 2020
This is the code the pipe that i am coding and is insulated and i need to incorporate that at x=0 dt/dx=0 but i am having trouble where to put it and how to put it
my graph is suppose to be flipped doing the at x=0 dt/dx=0
clear all
close all
Tinf=300;
Tb=400;
n=25;
L=1; %m
nsquare=25; %/m^2
dx=L/n;
aw=1/dx;
ae=aw;
ap=aw+ae+nsquare*dx;
A=zeros(n,n);
b=zeros(n,1);
for i=2:n-1 % number of equations
A(i,i)=ap; %Ap
A(i,i-1)=-aw; %Aw
A(i,i+1)=-ae; %Ae
b(i)=nsquare*dx*Tinf;
end
i=1
A(i,i)=3/dx+nsquare*dx; %Ap
A(i,i+1)=-1/dx; %Ae
b(i)=2*Tb/dx+nsquare*dx*Tinf;
i=n
A(i,i)=1/dx+nsquare*dx; %Ap
A(i,i-1)=-1/dx; %Aw
b(i)=nsquare*dx*Tinf;
T=linsolve(A,b)
hold on
figure(1)
plot(T)
title('Phi as function of grid point')
axis([0 n 0 100])
xlabel('i') % x-axis label
ylabel('Phi') % y-axis label
T_BC=zeros(n+2,1);
T_BC(1)=Tb;
for i=2:n+1 % number of equations
T_BC(i)=T(i-1);
end
T_BC(n+2)=T_BC(n+1);
y(1)=0;
y(2)=dx/2;
y(n+1)=L-dx/2;
y(n+2)=L;
for i=3:n % number of equations
y(i)=y(i-1)+dx;
end
figure(2)
plot(y,T_BC)
title('Phi as function of x')
xlabel('x') % x-axis label
ylabel('T') % y-axis label

Réponses (1)

Ashish Mishra
Ashish Mishra le 13 Oct 2020
The condition, dt/dx=0, is already included in the code because it implies that at that given x ,T(i)=T(i-1) and flip function can be used to flip the T matrix , so that the plot of T will be flipped.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by