Plot double Fourier series in MATLAB
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Daniel kiracofe
le 11 Nov 2016
0 votes
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.
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
