|
REM フーリエ級数展開(矩形波)アニメーション
OPTION ANGLE RADIANS
LET LEFT = -2*PI
LET RIGHT = 2*PI
LET BOTTOM = -2
LET TOP = 2
SET WINDOW LEFT, RIGHT, BOTTOM, TOP
DATA 1, 2, 3, 5, 10, 50
DIM N(0 TO 5)
MAT READ N
DRAW GRID
DO
FOR J = 0 TO 5
SET DRAW MODE HIDDEN ! 描画途中を画面に反映させない
SET AREA COLOR 0 ! 背景を白で塗りつぶす
PLOT AREA : LEFT,BOTTOM;RIGHT,BOTTOM;RIGHT,TOP;LEFT,TOP
DRAW GRID
FOR T = LEFT TO RIGHT STEP 0.02
LET S = 0
FOR I = 1 TO N(J) ! 1から第N(J)項まで足す
LET S = S + 1/(2*I-1)*SIN((2*I-1)*T)
NEXT I
PLOT LINES:T,S;
NEXT T
PLOT TEXT ,AT -0.8, -1.5, USING "N = >%":STR$(N(J))
SET DRAW MODE EXPLICIT ! 描画結果を画面に反映させる
WAIT DELAY 1 ! 処理を1秒停止
NEXT J
LOOP
END
|
|