IMG_20181203_165117.jpg

댓글 수: 2

madhan ravi
madhan ravi 2018년 12월 7일
upload the code that you tried
x=0:1:50;
syms n;
y=((2/pi)*((-1)^n+1)*(sin(pi*x)))/n;
symsum(y,n,1,inf);
figure(1);
plot(x,y)
i should say that i am a beginner.

댓글을 달려면 로그인하십시오.

 채택된 답변

HADIMARGO
HADIMARGO 2018년 12월 13일

0 개 추천

final answer by myself!!
x=linspace(-5,5,1000);
s=0;
for n=1:1:10000
p=((-1)^(n+1)*sin(n*pi*x))/n;
s=s+p;
end
f=(2/pi)*s;
plot(x,f)
final.jpg

추가 답변 (3개)

madhan ravi
madhan ravi 2018년 12월 7일
편집: madhan ravi 2018년 12월 7일

1 개 추천

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
HADIMARGO 2018년 12월 7일
편집: HADIMARGO 2018년 12월 7일
so tnx madhan ravi. i will send this answer to my teacher. if it correct i will get 1 score of 20 .
madhan ravi
madhan ravi 2018년 12월 7일
편집: madhan ravi 2018년 12월 7일
Anytime :) , read more about cumsum() and linspace()

댓글을 달려면 로그인하십시오.

HADIMARGO
HADIMARGO 2018년 12월 8일

0 개 추천

my teacher say it isnot correct. you should put it in a loop.

댓글 수: 1

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
HADIMARGO 2018년 12월 8일

0 개 추천

can anyone write complete answer with loop?

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2018년 12월 7일

답변:

2018년 12월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by