Compute double sum or double integral throug sum
Afficher commentaires plus anciens
x=[-20:0.2:10];
y=[-10:0.2:5];
u2=-3*exp(-sqrt(x.^2+y.^2)/2)
I want to sum this function from y=1 to the number of elements of y vector then the sum of this result from x=1 to the number of elements in x. IT is actually a double integral in form of sum.
2 commentaires
Adam
le 30 Oct 2017
You want to sum from y = 1 up to the number of elements in y even though y begins at -10 and runs to 5? How is that expected to work exactly?
Réponse acceptée
Plus de réponses (1)
Roger Stafford
le 30 Oct 2017
[X,Y] = meshgrid(x,y);
M = -3*exp(-sqrt(X.^2+Y.^2)/2);
S = sum(M(:))*.2*.2; % The desired sum
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!