Bonjour est ce que quelqu'un peu m'aider à corriger cette code pour que le coder de matlab puisse le transformer en C?
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function [y,Y,E,xbar,Delta,Eder,Etrue,SNRspars,sigmanoise]= mygenerdatatest(M,N,nb_pic,NoiseLevel)
 
% time samples
Tau = real(0:N-1); Tau = Tau(:);
DeltaTau = 0.5;
Tau = min(max(0,Tau+DeltaTau*(rand(N,1)-1/2)),N-1);
 
%frequences sur la grille
Theta = real((0:M-1)/M);
Theta = Theta(:);
%position of peaks
if(nb_pic==4)
    pos = [100 150 200 400];
elseif(nb_pic==6)
    pos = [100 150 200 250 300 400];
else
    q = randperm(M);
	pos = q((1:nb_pic));
end
 
%perturbation
Delta = zeros(M,1);
if(nb_pic==4)
    Delta(pos) = [0.1 -0.4 -0.3 0.2]/M;
elseif(nb_pic==6)
    Delta(pos) = [0.1 -0.4 -0.3 0.2 -0.1 -0.2]/M;
else
    Delta(pos) = (0.1/M).*ones(M,1) ;      
end
 
%frequences
Nu = Theta + Delta;
o = Nu(pos);
 
%modulus of peaks
if(nb_pic==6)
    Al = [0.5 0.9 1 0.7 0.8 0.6]';
elseif(nb_pic==4)
    Al = [0.5 0.9 1 0.7]';
else
    Al = ones(nb_pic,1);
end
 
%phase of peaks
fi = rand(nb_pic,1).*(2*pi);
 
%exact sparse signal we want to estimate
xbar = zeros(M,1);
for ind = 1:length(o)
    ocur = o(ind);
    xbar(Nu == ocur) = Al(ind)*exp(1i*fi(ind));
end
 
%exact cisoid (before adding noise)
sig = complex(zeros(50,1));
xx = complex(zeros(1,10));
for k = 1:nb_pic
   xx(k) = Al(k)*exp(1i*fi(k));
    sig = sig + xx(k)*exp(1i*2*pi*Tau*o(k));
end
 
%IFFT linear operator
E = exp(1i*2*pi*Tau*Theta');
 
%derivative
Eder = ((1i*2*pi*Tau/M)*ones(1,M)) .* exp(1i*2*pi*Tau*Theta');
 
% exact frequency matrix
Etrue = exp(1i*2*pi*Tau*Nu');
 
%observation
Y = sig(:);
sigmanoise =  std(Y) * 10^(-NoiseLevel/20);
z = randn(2*N,1);
y = Y + (sigmanoise/sqrt(2)) * (z(1:N,1) + 1i * z(N+1:end,1));
 
SNRspars = 20*log10(min(Al)/sigmanoise);
 
end
Merci!