Plot double Fourier series in MATLAB
이전 댓글 표시
I'd like to plot 'mesh' for both f and g functions in MATLAB.

I'd tried this for f and g:
clc
clear
close all
%%plot f
[x,y] = meshgrid(linspace(-pi,pi,50));
f=x.*y ;
subplot(1,2,1)
mesh(f)
title('f')
%%plot g
A=4*(-1)^(m+n)*(sin(m.*x)*sin(n.*y))/(m*n);
g=sum(sum(A,n,1,inf),m,1,inf);
subplot(1,2,2)
mesh(g)
title('g')
The result is:

I don't have any idea to plot g directly from its' function, any help would be appreciated.
채택된 답변
추가 답변 (1개)
Daniel kiracofe
2016년 11월 11일
0 개 추천
I think your problem is this line
A=4*(-1)^(m+n)*(sin(m.*x)*sin(n.*y))/(m*n);
from the way you have written it, it looks like you are expecting matlab to treat 'm' and 'n' as symbols here, for later evaluation in the sum command. But by default, matlab does not do symbolic computation. it does numeric computation. it is expecting m and n to be numbers (or vectors, or matrices). I think what you wanted to do was to first declare m and n to be symbols (i.e "syms n m"), and then use symsum() instead of sum(). Look up the documentation for the symbolic math toolbox for more information.
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
