All Courses
All Courses
clear all close all clc %% Getting the inputs sorted out % Total Number of Grid Points N = 5; % Domain length L = 0.5; % Grid spacing h = (L/N); % Spacial location (for exact soltion) x = 0:0.001:L; % Thermal conductivity k = 1000; % Area A = 10*10^-3; % Boundary conditions T_a = 100; T_b = 500; % initializing the tempetature…
Amith Ganta
updated on 21 Jun 2021
clear all
close all
clc
%% Getting the inputs sorted out
% Total Number of Grid Points
N = 5;
% Domain length
L = 0.5;
% Grid spacing
h = (L/N);
% Spacial location (for exact soltion)
x = 0:0.001:L;
% Thermal conductivity
k = 1000;
% Area
A = 10*10^-3;
% Boundary conditions
T_a = 100;
T_b = 500;
% initializing the tempetature
T(N) = 500;
T(1) = 100;
%% Forming the matrices
C(N,N) = 0;
D(N) = 0;
for i = 1:N
if i > 1 && i < N
C(i,i) = 2*k*A/h; %a_p
C(i,i-1) = -k*A/h; %-a_w
C(i,i+1) = -k*A/h; %-a_e
D(i) = 0;
elseif i==1 %Left boundary
C(i,i) = 3*k*A/h;
C(i,i+1) = -k*A/h;
D(i) = 2*k*(A/h)*T_a;
else %right boundary
C(i,i) = 3*k*A/h;
C(i,i-1) = -k*A/h;
D(i) = 2*k*(A/h)*T_b;
end
end
% Obtaining the solution
T = CD';
%% Plotting
% Spacial location of the grid points
x_g = h/2:h:(N)*h;
figure(1);
hold on
plot(x_g, T,'ro', 'Linewidth', 1) % Numerical Solution
plot([0 , L], [T_a, T_b], 'ko','Linewidth', 1) % Boundary values
xlabel('x (m)', 'interpret', 'Latex');
ylabel('T (K)', 'interpret', 'Latex');
set(gca, 'TicklabelInterpreter', 'Latex')
yticks([100:100:500]);
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Quater car modelling using Matlab
Quarter Car model …
22 Nov 2022 09:11 PM IST
Single cylinder SI engine modelling using GT-Suite
Introduction to GT Suite Effective utilization of simulation software with human intelligence is required…
03 Apr 2022 12:50 AM IST
internship formulas
∂ωx∂t=[2⋅a2a2+c2−2⋅a2a2+b2]⋅ωz⋅ωy+Posin(t)⋅2⋅a2a2+b2⋅ωZ+2⋅a2a2+c2⋅ωy+Posin(t)+L⋅τx ∂ωy∂t=[2⋅b2a2+b2−2⋅b2b2+c2]⋅ωx⋅ωz+Pocos(t)⋅2⋅b2a2+b2⋅ωZ−2⋅b2b2+c2⋅ωx+Pocos(t)+L⋅τy…
30 Oct 2021 02:16 PM IST
CI engine modelling of 2019 Chevrolet Silverado Duramax Diesel Engine Using GT Suite
Introduction to CI engines Compression - ignition or diesel engine…
17 Sep 2021 09:30 AM IST
Related Courses
0 Hours of Content