HOW SHOULD DRAW THIS IN LOOP FORM? WHERE IS THE PROBLEM IN MY CODE?
조회 수: 1 (최근 30일)
이전 댓글 표시
my code:
s=0;
for n=1:0.01:10
s=s+(-1^n+1*sin(n*pi*x));
end
f=(2/pi)*s;
plot(x,f)
Where is wrong in my code?
댓글 수: 4
Walter Roberson
2018년 12월 13일
You are defining x to have only 11 points, to exist only at the integers. Your required plot is clearly defined much denser than that.
채택된 답변
추가 답변 (1개)
madhan ravi
2018년 12월 13일
x=linspace(-5,5,10000);
s=0;
for n=1:0.01:10
s=s+(-1^n+1*sin(n*pi*x));
end
f=(2/pi)*s;
plot(x,f)
참고 항목
카테고리
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!