Double fourier series in MATLAB -
i'd plot mesh both f , g functions below in matlab: 
i'd tried f , g:
%% plot f [x,y] = meshgrid(linspace(-pi,pi,50)); f = x.*y ; subplot(1,2,1) mesh(f) title('f') %% plot g syms m n = 4*(-1)^(m+n)*(sin(m*x)*sin(n*y))/(m*n); g = symsum(symsum(a,n,1,inf),m,1,inf); subplot(1,2,2) mesh(g) title('g') the result of mesh is:

the section plotting f running without error. other section plotting g show nothing in figure. how can plot g?
if you're going work symbolic math, it's idea comfortable assumptions, when dealing periodic functions , functions discontinuities. may want use fmesh (or ezmesh in older versions) plot meshes of symbolic expressions:
syms m n x y assume(in(m,'integer') & m>=1); assume(in(n,'integer') & n>=1); assume(x>-pi & x<pi); assume(y>-pi & y<pi); = 4*(-1)^(m+n)*(sin(m*x)*sin(n*y))/(m*n); g = symsum(symsum(a,n,1,inf),m,1,inf); fmesh(g,5*[-pi pi -pi pi],'meshdensity',1e2); % or ezmesh(g,5*[-pi pi -pi pi]); another option evaluate g numerically using subs , double , use mesh plot:
[x,y] = meshgrid(linspace(-5*pi,5*pi,100)); g2 = real(double(subs(g,{x,y},{x,y}))); mesh(g2); or use matlabfunction create numeric function:
g2 = matlabfunction(g); [x,y] = meshgrid(linspace(-5*pi,5*pi,100)); mesh(real(g2(x,y))); in both these latter cases, real must used clip insignificant imaginary parts due numerical imprecision.

Comments
Post a Comment