HOW I COULD DRAW THIS FUNCTION
3 ビュー (過去 30 日間)
古いコメントを表示
2 件のコメント
採用された回答
その他の回答 (3 件)
madhan ravi
2018 年 12 月 7 日
編集済み: madhan ravi
2018 年 12 月 7 日
Use cumsum() to define the behaviour of the alternating series:
x=linspace(0,50,10000);
n=1:10000;
y=(2/pi).*cumsum((((-1).^n+1).*(sin(pi.*x)))./n);
figure(1);
plot(x,y)
2 件のコメント
madhan ravi
2018 年 12 月 7 日
編集済み: madhan ravi
2018 年 12 月 7 日
Anytime :) , read more about cumsum() and linspace()
HADIMARGO
2018 年 12 月 8 日
1 件のコメント
Walter Roberson
2018 年 12 月 8 日
If you have TheResult = cumsum(SomeVector) then you can recode that in a loop as
TheResult(1) = SomeVector(1);
for LoopVariable = 2 : length(SomeVector)
TheResult(LoopVariable) = TheResult(LoopVariable-1) + SomeVector(LoopVariable);
end
... Approximately.
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!