Plotting temperature distribution versus time.
9 views (last 30 days)
Show older comments
Hello everyone,
I have this temperature distribution function shown in the picture and wanted to plot it versus time. I would like to mention the (x) domain to be from 0 to 1. I have tried the following code but it did not work at all. Can someone please solve my problem? I would really appreciate your help and time spent on solving the problem. Thanks in advance.
clc
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 18;
fprintf('Beginning to run %s.m ...\n', mfilename);
numPoints = 64;
t = 100;
L = 1;
x = linspace(0, L, numPoints);
t1 = linspace(0, t, numPoints);
n = 1;
T = zeros(numPoints);
Theta = zeros(numPoints);
for it = 1 : numPoints
this_t = t(it);
for jx = 1:numPoints
this_x = x(jx);
theSum = 0;
for n = 1 : 100
term1 = -100*(-1)^n/(pi*n);
term2 = exp(-(n*pi)^2)*this_t;
term3 = sin(n * pi * this_x);
theSum = theSum + term1 * term2 * term3;
end
T(it, jx) = -100*this_x + 100 + theSum;
end
end
imshow(T, [], 'XData', x, 'YData', t, 'InitialMagnification', 1600);
fplot(t,T);
axis('on', 'image');
title('T(t, x)', 'FontSize', 15);
xlabel('x', 'FontSize', 15);
ylabel('t', 'FontSize', 15);
fprintf('Done running %s.m ...\n', mfilename);
0 Comments
Answers (0)
See Also
Categories
Find more on Line Plots 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!