How to Plot a function that contains summation?
조회 수: 31 (최근 30일)
이전 댓글 표시
How can I plot the attached two functions with limits from -pi to pi for different values of m ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/743494/image.png)
댓글 수: 5
Walter Roberson
2021년 9월 20일
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
채택된 답변
Walter Roberson
2021년 9월 20일
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
Walter Roberson
2021년 9월 20일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!