HOW I COULD DRAW THIS FUNCTION
조회 수: 2 (최근 30일)
이전 댓글 표시
![IMG_20181203_165117.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/198513/IMG_20181203_165117.jpeg)
댓글 수: 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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/198516/image.png)
댓글 수: 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!