MATLAB: How to plot the following in MATLAB

3d plotsplotplottingsubplot

Hello Everyone! Could anyone help me plot the following Fourier Cosine series,
,
where the fourier cosine coefficients are
,
, .
I tried the following code for a specific value of n=8 just to check it but it does not give me the correct results.
clear all, clc
syms x t k
for t=0:0.5
bo=1.40985;
bl=-0.443179;
t1=exp(-(k^2)*(pi^2)*t);
t2=k*sin(k*pi*x);
t3=cos(k*pi*x);
S1=symsum((bl*t1*t2),k,1,8);
S2=symsum((bl*t1*t3),k,1,8);
S3=bo+S2;
S4=S1/S3;
u=((-pi)*S4);
end
fplot(u)

Best Answer

Not sure if this is what you are looking for or not.
for n=0:8
f=@(x)exp((1-cos(pi*x))/pi.*cos(n*pi*x));
b(n+1)=2*integral(f,0,1);
end
b(1)=b(1)/2;
[x,t]=meshgrid(0.09:.0001:.1,0:.0001:.01);
n=zeros(size(x));
d=zeros(size(x));
for bb=2:9
n=n+b(bb)*exp(-bb^2*pi^2*t)*bb*sin(bb*pi*x);
d=d+b(bb)*exp(-bb^2*pi^2*t)*cos(bb*pi*x);
end
d=ones(size(x))*b(1)+d;
u=-pi*n./d;
surf(x,t,u,'EdgeColor','none');