Soyez le premier à donner votre avis sur cette source.
Vue 5 937 fois - Téléchargée 549 fois
Option Explicit Private Const pi = 3.14159265 '********************************************************* Public Type COMPLEXE Reel As Double 'an dans fourrier Img As Double 'bn dans fourrier End Type '--------------------------------------------------------- Public Type FT periode As Integer Nmax As Integer coef() As COMPLEXE End Type '--------------------------------------------------------- Public Function Norme(C As COMPLEXE) As Double Norme = Sqr(C.Reel * C.Reel + C.Img * C.Img) End Function '--------------------------------------------------------- Public Function Phase(C As COMPLEXE) As Double Phase = Atn(C.Img / C.Reel) End Function '********************************************************* Public Function Fourrier_Transform(f() As Integer, Nmax As Integer) As FT Fourrier_Transform.periode = UBound(f) - LBound(f) + 1 Fourrier_Transform.Nmax = Nmax ReDim Fourrier_Transform.coef(0 To Nmax) Dim n As Integer For n = 0 To Nmax Step 1 Fourrier_Transform.coef(n).Reel = An(f, n) Fourrier_Transform.coef(n).Img = Bn(f, n) If (Fourrier_Transform.coef(n).Reel > 1) Or _ (Fourrier_Transform.coef(n).Img > 1) Then Fourrier_Transform.Nmax = n End If Next ReDim Preserve Fourrier_Transform.coef(0 To Fourrier_Transform.Nmax) End Function Public Function Fourrier_Transform_Inv(f As FT, ift() As Integer) Dim min As Integer: min = 1 Dim max As Integer: max = f.periode ReDim ift(1 To max - min + 1) Dim i As Integer Dim n As Integer For i = min To max ift(i) = f.coef(0).Reel 'A0 For n = 1 To f.Nmax ift(i) = ift(i) + f.coef(n).Reel * Cos(2 * pi * n * i / f.periode) ift(i) = ift(i) + f.coef(n).Img * Sin(2 * pi * n * i / f.periode) Next Next End Function Private Function An(f() As Integer, n As Integer) As Double Dim i As Integer Dim t As Integer t = (UBound(f) - LBound(f) + 1) If (n = 0) Then For i = LBound(f) To UBound(f) An = An + f(i) Next An = An / t Else For i = LBound(f) To UBound(f) An = An + (f(i) * Cos(2 * pi * n * i / t)) Next An = An * 2 / t End If End Function Private Function Bn(f() As Integer, n As Integer) As Double Dim i As Integer Dim t As Integer t = (UBound(f) - LBound(f) + 1) If (n = 0) Then Bn = 0 Else For i = LBound(f) To UBound(f) Bn = Bn + (f(i) * Sin(2 * pi * n * i / t)) Next Bn = Bn * 2 / t End If End Function
Commentaires
tu pourrais s'il te plait intégré un exécutable de ta form, dans ton zip ? merci bien
Tu classe ta source en débutant, je la trouve déjà pas trop mal.
Peut être que c'est parsque je ne sais déja pas évoluer mon propre niveau ^^
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.