HOW I COULD DRAW THIS FUNCTION
2 次查看(过去 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 个评论
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!