Bonjour,
je travaille actuellement sur le calcule des moments de Tchebychev ,mais hélas ça n'a pas voulu bien fonctionner voila j'ai développé un code en MATLAB qui est constitué de trois fonctions : ChebyshevPoly,phi_j et moment, le résultat de la fonction moment me donne tout le temps 0.
Je ne comprends pas mon erreur,merci de m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 function tk = ChebyshevPoly(n) if n==0 tk = 1; elseif n==1 tk = [1 0]'; else tkm2 = zeros(n+1,1); tkm2(n+1) = 1; tkm1 = zeros(n+1,1); tkm1(n) = 1; for k=2:n tk = zeros(n+1,1); for e=n-k+1:2:n tk(e) = 2*tkm1(e+1) - tkm2(e); end if mod(k,2)==0 tk(n+1) = (-1)^(k/2); end if k<n tkm2 = tkm1; tkm1 = tk; end end end
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function out=phi_j(n,N) %PHI_J Summary of this function goes here % Detailed explanation goes here %out=factorial(2*n)*[N+n; 2*n+1]; %out=factorial(N+n)/(2*n+1)*factorial(N-n); mol=1; for i=1:n, mol=mol*(N^2-i^2); end out=(N^2*mol)/(2*n+1)*10^-6; end
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 function [ T_mn ] = moment( f,n,m) %MOMENT Summary of this function goes here % Detailed explanation goes here [N,M]=size(f); som=0; for x=1:N, for y=1:M, % Polyval(ChebyshevPoly(n),x) som = som + (Polyval(ChebyshevPoly(n),x) * Polyval (ChebyshevPoly(m),y)* f(x,y)); end end som; % phi_j(n,N) % phi_j(m,M) % 1/(phi_j(n,N) % 1/phi_j(m,M) % (1/(phi_j(n,N))*(1/phi_j(m,M))) T_mn=(1/(phi_j(n,N)*phi_j(m,M))).*som; end
Partager