MATLAB: How to plot the log to base 10 of absolute value of a function containing Sigma (Σ)

3d plotsgraphingMATLAB

How can I do this plot in MATLAB?

Best Answer

Try this code, it might help.
clear all
close all
Nt = 100;
Nx = 150;
L = 2;
a = .5;
t = 0:4/(Nt-1):4;
x = 0:L/(Nx-1):L;
[t,x] = meshgrid(t,x);
q = zeros(Nt,Nx);
M = 500;
for n = 1:M
an = (2*n-1)/(2*L);
bn = an*pi;
cn = bn^2;
An = (-1)^n/(1+a*cn);
xn = exp(-cn*t/(1+a*cn));
yn = sin(bn*x);
q = q + An*yn'.*xn';
end
qabs = log10(abs(q));
surf(t',x',qabs)
colormap('winter')
xlabel('t');
ylabel('x');
zlabel('10log|q|')