一個の神経細胞(neuro)

 投稿者:SECOND  投稿日:2009年 1月18日(日)10時37分30秒
  !
! 一個の神経細胞(neuro)
! その カオス(chaos)を、探し、見る、ツール
!
!----------------------------
! "Neuro12"
!
! 2009.1.18
!----------------------------
OPTION ARITHMETIC NATIVE
OPTION BASE 0
SET TEXT background "OPAQUE"
SET POINT STYLE 1
SET AREA COLOR 0
LET DLY=50
DIM St(1,DLY) ,Sy(2000), B4(0,500)
!
LET Kr=0.5
LET Af=1
LET Ei=-70
LET Ss=0.31 ! Ss=(Kr-1)(theta-s(t)) …s(t)=0
LET theta=Ss/(Kr-1)

DEF Ri(Yi,Ss)=Kr*Yi-Af/(1+EXP(Ei*Yi))+Ss

PLOT TEXT,AT .04,.96:"*** Neuro Cell"
PLOT TEXT,AT .04,.92:"Right Click to Stop"
PLOT TEXT,AT .04,.89:"Left  Click & Drag '|' Line"
!
!-----
LET Y0=Af/100
LET Af2=Af
DO
   LET Af=Af2
   CALL ma200_
   ! ma100_
   !----- clear
   SET WINDOW -Af*2.07-Af*1.06,Af*2.07-Af*1.06,-Af*2.07-Af*1.05,Af*2.07-Af*1.05
   PLOT AREA: -Af,-Af;Af,-Af;Af,Af;-Af,Af
   !----- box outline
   SET LINE COLOR "blue"
   PLOT LINES: -Af,-Af; Af,-Af; Af,Af; -Af,Af; -Af,-Af
   !-----
   PLOT TEXT,AT Af*.03,Af*.85: "+Af Y(t+1)"
   PLOT TEXT,AT -Af*.97,Af*0.13: "Y(t)"
   PLOT TEXT,AT -Af*.97, 0: "-Af"
   PLOT TEXT,AT Af*.8, 0: "+Af"
   PLOT TEXT,AT Af*.03,-Af*.98: "-Af"
   !----- Sy(w)=Y(t)
   LET imax=pixelx(Af)-pixelx(-Af)
   LET dA1=(Af+Af)/imax
   FOR i=0 TO imax
      LET Sy(i)=Ri(-Af+i*dA1, Ss)
   NEXT i
   !-----
   DO
      LET Y1=Ri(Y0,Ss)
      !----- erase old signal
      LET W0=St(0,t)
      LET W1=St(1,t)
      FOR i=0 TO DLY-1
         IF W0=St(0,i) AND W1=St(1,i) AND t<>i THEN EXIT FOR
      NEXT i
      IF DLY=i THEN
         SET LINE COLOR 0
         PLOT LINES: W0,W0; W0,W1;
         PLOT LINES: W1,W1
      END IF
      !----- axis
      SET LINE COLOR "cyan" ! axis_Y(t)… ―
      PLOT LINES: -Af,0; Af,0
      SET LINE COLOR "magenta" ! axis_Y(t+1)…|
      PLOT LINES: 0,-Af; 0,Af
      !----- draw curve Y(t)
      SET LINE COLOR 1
      FOR i=0 TO imax
         PLOT LINES: -Af+i*dA1, Sy(i);
      NEXT i
      PLOT LINES
      !----- signal
      SET LINE COLOR "cyan" ! input_Y(t)…|
      PLOT LINES: Y0,Y0; Y0,Y1;
      SET LINE COLOR "magenta" ! output_Y(t+1)… ―
      PLOT LINES: Y1,Y1
      !-----
      LET St(0,t)=Y0
      LET St(1,t)=Y1
      LET t=MOD(t+1,DLY)
      LET Y0=Y1
      !-----
      WAIT DELAY .02
      MOUSE POLL x,y,mlb,mrb
   LOOP UNTIL mlb=1 OR mrb=1
   !
   !----- cursor input
   IF mlb=1 THEN
      SET WINDOW -0.1*Af,Af, -Af*2.1+Af*1.08,Af*2.1+Af*1.08
      DO
         MOUSE POLL x,y,mlb,mrb
         IF 0<=x AND x<=Af THEN
            IF y< Af THEN
               IF bx4<>pixelx(x) THEN
                  LET Ss=x
                  LET theta=Ss/(Kr-1)
                  CALL cursor4( bx4,B4)
               END IF
            ELSEIF x< Af*.43 THEN
               IF y< Af*1.4 THEN
               ELSEIF y< Af*1.7 THEN
                  IF bx3<>pixelx(x) THEN
                     LET Ei=x*120/(Af*.43)-120
                     CALL cursor13( bx3, 1.7, 1.4)
                  END IF
               ELSEIF y< Af*2.1 THEN
                  IF bx2<>pixelx(x) THEN
                     LET Kr=x*1/(Af*.43)
                     LET theta=Ss/(Kr-1)
                     CALL cursor13( bx2, 2.1, 1.8)
                  END IF
               ELSEIF y< Af*2.5 THEN
                  IF bx1<>pixelx(x) THEN
                     LET Af2=x*2/(Af*.43)+0.5
                     MAT St=ZER
                     LET Y0=Af/100
                     CALL cursor13( bx1, 2.5, 2.2)
                  END IF
               END IF
            END IF
         END IF
         WAIT DELAY .05
      LOOP UNTIL mlb=0
   END IF
LOOP UNTIL mrb=1

SUB cursor4( bx,B(,))
   MAT PLOT CELLS, IN worldx(bx),Af; worldx(bx),-Af: B
   LET bx=pixelx(x)
   ASK PIXEL ARRAY (x,Af) B
   SET LINE COLOR "red"
   PLOT LINES: x,-Af; x,Af
   PLOT TEXT,AT 0,Af,USING "Kr=#.### :Af=#.### :Ei=####.# :Ss=#.### :theta=####.###": Kr, Af, Ei, Ss, theta
END SUB

SUB cursor13( bx, uy,ly)
   SET LINE COLOR 0
   PLOT LINES: worldx(bx),Af*uy-dAy; worldx(bx),Af*ly+dAy
   LET bx=pixelx(x)
   SET LINE COLOR "red"
   PLOT LINES: x,Af*uy-dAy; x,Af*ly+dAy
   PLOT TEXT,AT 0,Af,USING "Kr=#.### :Af=#.### :Ei=####.# :Ss=#.### :theta=####.###": Kr, Af2, Ei, Ss, theta
END SUB

SUB ma200_
!----- clear
   SET WINDOW -0.1*Af,Af, -Af*2.1+Af*1.08,Af*2.1+Af*1.08
   PLOT AREA: 0,-Af;Af,-Af;Af,Af;0,Af
   !----- box outline
   SET LINE COLOR "blue"
   PLOT LINES: 0,-Af; Af,-Af; Af,Af; 0,Af; 0,-Af
   PLOT LINES: 0,0; Af,0
   !-----
   PLOT TEXT,AT -.06*Af,.9*Af : "+Af"
   PLOT TEXT,AT -.07*Af,-.05*Af : "Y(t)"
   PLOT TEXT,AT -.06*Af,-Af : "-Af"
   PLOT TEXT,AT Af*.5,-Af*.98: "0 <--- Ss ---> +Af"
   !-----
   LET dA2=Af/(pixelx(Af)-pixelx(0))
   LET dAy=Af/(pixely(Af)-pixely(0))
   LET Yt=0 ! Y(t)
   FOR j=0 TO Af STEP dA2 ! j= Ss= (Kr-1)*theta
      FOR i=0 TO 99
         LET Yt=Ri(Yt,j)
         PLOT POINTS: j,Yt
      NEXT i
   NEXT j
   !----- setup cursor Ss
   LET x=Ss
   ASK PIXEL SIZE (x,Af;x,-Af) i,j
   MAT B4=ZER(0,j-1)
   ASK PIXEL ARRAY (x,Af) B4
   LET bx4=pixelx(x)
   CALL cursor4( bx4, B4)
   !-----
   LET x=(Ei+120)*Af*.43/120 !// Ei=x*120/(Af*.43)-120
   LET bx3=pixelx(x)
   CALL cursor130( bx3, 1.7, 1.4, "Ei")
   LET x=Kr*Af*.43 !// Kr=x*1/(Af*.43)
   LET bx2=pixelx(x)
   CALL cursor130( bx2, 2.1, 1.8, "Kr")
   LET x=(Af-0.5)*Af*.43/2 !// Af2=x*2/(Af*.43)+0.5
   LET bx1=pixelx(x)
   CALL cursor130( bx1, 2.5, 2.2, "Af")
END SUB

SUB cursor130( bx, uy, ly, w$)
   PLOT TEXT,AT -.06*Af,Af*(uy-0.2): w$
   SET LINE COLOR "blue"
   PLOT LINES: 0,Af*uy; Af*.43,Af*uy; Af*.43,Af*ly; 0,Af*ly; 0,Af*uy
   CALL cursor13( bx, uy, ly)
END SUB

END
 

戻る