Plot 1D heat equation solve by Fourier transform into MATLAB

I'm solving for this equation below (which I believed to be a 1d heat equation) with initial condition of .
Here are just constants. I'm solving for the general case instead of a specific pde.
Apparently I the solution involves triple convolution, which ends up with a double integral. What I did was I made a function in a separate file, and then try to calculate the integral using integral2 through a loop and then plot the graph. What I don't understand is how do I specify MATLAB to integrate with respect to w and then z? Here is my code so far, and it seems to get caught in an infinite loop? The function I'm integrate is called "Integrals_18June". The solution Im trying to plot is below
sigma = 1;
mu = -1;
x1 = 1; % counter
t1 = 1; % counter
[X,T]=meshgrid(-15:0.5:15,0.1:0.2:1);
U = [];
for t = transpose(T(:,1))
for x = X(1,:)
% Incorporate coefficients
integ = integral2(@(w,z) Integrals_18June(z,w,x,t,sigma),-Inf,Inf,-Inf,Inf);
U(t1,x1)=integ*exp(mu*t)/(2*pi);
x1 = x1 +1;
end
t1 = t1+1;
x1 = 1;
end
surf(X,T,U);
xlabel("X");
ylabel("T");
zlabel("U");

Answers (1)

Hi Vicky,
Set the Integration method to 'iterated' for the 'Method' name-value pair in the input arguments of the function integral2.
Once this is specified, integral2 calls integral to perform an iterated integral. The outer integral is evaluated over xmin ≤ x ≤ xmax. The inner integral is evaluated over ymin(x) ≤ y ≤ ymax(x). The integration limits can be infinite.
Refer to the documentation of integral2 for more information. Hope this helps!

Asked:

on 17 Jun 2021

Answered:

on 21 Jun 2021

Community Treasure Hunt

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

Start Hunting!