フィルターのクリア

How to Plot a function that contains summation?

13 ビュー (過去 30 日間)
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2021 年 9 月 20 日
コメント済み: Walter Roberson 2021 年 9 月 20 日
How can I plot the attached two functions with limits from -pi to pi for different values of m ?
  5 件のコメント
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2021 年 9 月 20 日
With below I am getting an error (Undefined function 'symsum' for input arguments of type 'double'.)
x=[-pi:1:pi]
syms m
figure
for m=1:10
Function_5=(pi/2) + symsum(((2*(-1)^m-1)*cos(m.*x)/pi*m^2),m,0,10)
plot(Function)
hold on
end
Walter Roberson
Walter Roberson 2021 年 9 月 20 日
x=[-pi:0.1:pi]
x = 1×63
-3.1416 -3.0416 -2.9416 -2.8416 -2.7416 -2.6416 -2.5416 -2.4416 -2.3416 -2.2416 -2.1416 -2.0416 -1.9416 -1.8416 -1.7416 -1.6416 -1.5416 -1.4416 -1.3416 -1.2416 -1.1416 -1.0416 -0.9416 -0.8416 -0.7416 -0.6416 -0.5416 -0.4416 -0.3416 -0.2416
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
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 件のコメント
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2021 年 9 月 20 日
I am trying this but its not working
Walter Roberson
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 ExchangeCalculus についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by