直接修改你的代码如下:
x=-2:.1:2;
t=-2:.1:2;
[X,T]=meshgrid(x,t);
n=reshape(0:1:100,1,1,[]);
Z = 0.96./(pi.^3).*sum(bsxfun(@times, 1./(2*n-1).^3, cos(bsxfun(@times, (2*n-1)*pi, T)).*sin(bsxfun(@times, (2*n-1)*pi, X/2))),3);
surf(X,T,Z)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!