' nm6lib.bas - jackord@kw.igs.net - revised 16 Feb 08 - Liberty Basic v4.02 ' FFSS coefficients for Pulse A and Pulse B ' on a n-segment string clamped at both ends ' Initialize Window nomainwin button#1, "Pulse A", [p1], UL, 92, 5, 60, 20 button#1, "Pulse B", [p2], UL, 162, 5, 60, 20 dim a$(5) a$(0)="n=48": a$(1)="n=96": a$(2)="n=192": a$(3)="n=384" combobox#1.c1, a$(, [waitHere], 232, 5, 70, 120 WindowWidth=410 ' Pixel Scale 0-392 WindowHeight=306 ' Pixel Scale 0-268 UpperLeftX=10: UpperLeftY=10 open "FFSS Coefficients" for graphics_nsb as #1 #1 "trapclose [quit] ; down" #1.c1 "selectindex 1" kk=0: plt=0 dim y(385): dim v(385): dim yy(65) dim b(65): dim d(65): dim w(65) [waitHere] wait [p1] kk=1: goto [plot] [p2] kk=2: goto [plot] [plot] #1 "cls" #1 "color black ; line 8 260 384 260 ; line 8 260 8 8" #1.c1 "selectionindex?": input#1.c1, ind n=48*int(2^(ind-1)) if n=48 then nm=n else nm=64 redim y(n+1): redim v(n+1) redim w(nm+1): redim b(nm+1): redim d(nm+1): redim yy(nm+1) pi=4*atn(1): s=0 for i=3*n/8 to 5*n/8 ' Init Pulse A z=(i-3*n/8)*pi/(n/8) y(i)=40*(1-cos(z)) v(i)=0-40*pi/(n/8)*sin(z) if kk=2 then ' Init Pulse B v(i)=v(i)*cos(4*z)+y(i)*4*pi/(n/8)*sin(4*z) y(i)=y(i)*cos(4*z) end if next i for i=1 to nm w(i)=2*sin(pi*i/2/n) for j=1 to n-1 b(i)=b(i)+2*y(j)*sin(pi*i*j/n)/n d(i)=d(i)+2*v(j)/w(i)*sin(pi*i*j/n)/n next j s=s+b(i)*b(i)+d(i)*d(i) next i #1 "color red ; backcolor red" for i=1 to nm yy(i)=260-int(1200*(b(i)*b(i)+d(i)*d(i))/s+.5) if yy(i)<259.5 then #1 "place "; 8+6*i-2; " 260" #1 "boxfilled "; 8+6*i+3; " "; yy(i) end if next i k=0: z=0 while z/s<.9999 k=k+1: z=z+b(k)*b(k)+d(k)*d(k) wend #1 "color blue ; backcolor white ; place 8 260" if n=48 then nm=288 else nm=384 for i=n/48 to nm step nm/48 #1 "goto "; 8+i; " "; 260-int(2.4*n*sin(i*pi/12/n)+.5) next i #1 "color black ; place 80 45" #1 "\For Nmax = "; k #1 "place 200 45" #1 "\Percent = "; int(100000*z/s)/1000 goto [waitHere] [quit] close #1 end