How to Plot a function that contains summation?
54 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Muhammad Qaisar Fahim
le 20 Sep 2021
Commenté : Walter Roberson
le 20 Sep 2021
How can I plot the attached two functions with limits from -pi to pi for different values of m ?
5 commentaires
Walter Roberson
le 20 Sep 2021
x=[-pi:0.1:pi]
figure
for alpha=1:10
m = (1:alpha).';
Function_5 = (pi/2) + sum(((2 .* (-1).^m-1) .* cos(m.*x) ./ (pi .* m.^2)),1);
plot(x, Function_5, 'displayname', "\alpha = " + alpha);
hold on
end
legend show
Réponse acceptée
Walter Roberson
le 20 Sep 2021
alpha = 8;
m = (1:alpha).';
f = @(x) 2/pi + sum(2 .* ((-1).^m - 1)./(pi .* m.^2) .* cos( m.*x ), 1);
fplot(f, [-pi pi])
3 commentaires
Walter Roberson
le 20 Sep 2021
syms x m
figure
for alpha=1:10
Function_5 = (pi/2) + symsum(((2*(-1)^m-1)*cos(m.*x)/pi*m^2),m,0,alpha);
fplot(Function_5, [-pi pi], 'DisplayName', "\alpha = " + alpha);
hold on
end
legend show
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!