HOW I COULD DRAW THIS FUNCTION
이전 댓글 표시
채택된 답변
추가 답변 (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일
0 개 추천
댓글 수: 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.
HADIMARGO
2018년 12월 8일
0 개 추천
댓글 수: 1
Walter Roberson
2018년 12월 8일
Yes, we could, but it is your homework.
카테고리
도움말 센터 및 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!

